diff --git a/workflow/engine/classes/model/OutputDocument.php b/workflow/engine/classes/model/OutputDocument.php
index 3e12b94e3..33e44de1d 100755
--- a/workflow/engine/classes/model/OutputDocument.php
+++ b/workflow/engine/classes/model/OutputDocument.php
@@ -24,8 +24,8 @@
*
*/
-require_once 'classes/model/om/BaseOutputDocument.php';
-require_once 'classes/model/Content.php';
+require_once ("classes/model/om/BaseOutputDocument.php");
+require_once ("classes/model/Content.php");
/**
* Skeleton subclass for representing a row from the 'OUTPUT_DOCUMENT' table.
@@ -38,799 +38,905 @@ require_once 'classes/model/Content.php';
*
* @package workflow.engine.classes.model
*/
-class OutputDocument extends BaseOutputDocument {
+class OutputDocument extends BaseOutputDocument
+{
+ /**
+ * This value goes in the content table
+ * @var string
+ */
+ protected $out_doc_title = '';
- /**
- * This value goes in the content table
- * @var string
- */
- protected $out_doc_title = '';
+ /**
+ * This value goes in the content table
+ * @var string
+ */
+ protected $out_doc_description = '';
- /**
- * This value goes in the content table
- * @var string
- */
- protected $out_doc_description = '';
+ /**
+ * This value goes in the content table
+ * @var string
+ */
+ protected $out_doc_filename = '';
- /**
- * This value goes in the content table
- * @var string
- */
- protected $out_doc_filename = '';
+ /**
+ * This value goes in the content table
+ * @var string
+ */
+ protected $out_doc_template = '';
- /**
- * This value goes in the content table
- * @var string
- */
- protected $out_doc_template = '';
+ public function __construct()
+ {
+ $javaInput = PATH_C . 'javaBridgePM' . PATH_SEP . 'input' . PATH_SEP;
+ $javaOutput = PATH_C . 'javaBridgePM' . PATH_SEP . 'output' . PATH_SEP;
-
- function __construct() {
- $javaInput = PATH_C . 'javaBridgePM' . PATH_SEP . 'input' . PATH_SEP;
- $javaOutput = PATH_C . 'javaBridgePM' . PATH_SEP . 'output' . PATH_SEP;
- G::mk_dir ( $javaInput );
- G::mk_dir ( $javaOutput );
- }
-
- public function getByUid($sOutDocUid)
- {
- try {
- $oOutputDocument = OutputDocumentPeer::retrieveByPK( $sOutDocUid );
- if( is_null($oOutputDocument) )
- return false;
-
- $aFields = $oOutputDocument->toArray(BasePeer::TYPE_FIELDNAME);
- $aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle();
- $aFields['OUT_DOC_DESCRIPTION'] = $oOutputDocument->getOutDocDescription();
- $aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename();
- $aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate();
- $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
- return $aFields;
+ G::mk_dir($javaInput);
+ G::mk_dir($javaOutput);
}
- 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);
- $aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle();
- $aFields['OUT_DOC_DESCRIPTION'] = $oOutputDocument->getOutDocDescription();
- $aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename();
- $aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate();
- $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
- return $aFields;
- }
- else {
- throw(new Exception('This row doesn\'t exist!'));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
+ public function getByUid($sOutDocUid)
+ {
+ try {
+ $oOutputDocument = OutputDocumentPeer::retrieveByPK($sOutDocUid);
- /**
- * 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';
+ if (is_null($oOutputDocument)) {
+ return false;
+ }
+
+ $aFields = $oOutputDocument->toArray(BasePeer::TYPE_FIELDNAME);
+ $aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle();
+ $aFields['OUT_DOC_DESCRIPTION'] = $oOutputDocument->getOutDocDescription();
+ $aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename();
+ $aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate();
+ $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
+
+ return $aFields;
+ } catch (Exception $oError) {
+ throw ($oError);
}
- }
- $oOutputDocument = new OutputDocument();
- $oOutputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
- if ($oOutputDocument->validate()) {
- $oConnection->begin();
- if (isset($aData['OUT_DOC_TITLE'])) {
- $oOutputDocument->setOutDocTitle($aData['OUT_DOC_TITLE']);
+ }
+
+ /*
+ * 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);
+ $aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle();
+ $aFields['OUT_DOC_DESCRIPTION'] = $oOutputDocument->getOutDocDescription();
+ $aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename();
+ $aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate();
+ $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
+
+ return $aFields;
+ } else {
+ throw(new Exception('This row doesn\'t exist!'));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
}
- if (isset($aData['OUT_DOC_DESCRIPTION'])) {
- $oOutputDocument->setOutDocDescription($aData['OUT_DOC_DESCRIPTION']);
+ }
+
+ /**
+ * 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->setOutDocTitle($aData['OUT_DOC_TITLE']);
+ }
+
+ if (isset($aData['OUT_DOC_DESCRIPTION'])) {
+ $oOutputDocument->setOutDocDescription($aData['OUT_DOC_DESCRIPTION']);
+ }
+
+ $oOutputDocument->setOutDocFilename($aData['OUT_DOC_FILENAME']);
+
+ if (isset($aData['OUT_DOC_TEMPLATE'])) {
+ $oOutputDocument->setOutDocTemplate($aData['OUT_DOC_TEMPLATE']);
+ }
+
+ $iResult = $oOutputDocument->save();
+ $oConnection->commit();
+
+ 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);
}
- $oOutputDocument->setOutDocFilename($aData['OUT_DOC_FILENAME']);
- if (isset($aData['OUT_DOC_TEMPLATE'])) {
- $oOutputDocument->setOutDocTemplate($aData['OUT_DOC_TEMPLATE']);
+ }
+
+ /**
+ * 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->setOutDocTitle($aData['OUT_DOC_TITLE']);
+ }
+
+ if (isset($aData['OUT_DOC_DESCRIPTION'])) {
+ $oOutputDocument->setOutDocDescription($aData['OUT_DOC_DESCRIPTION']);
+ }
+
+ if (isset($aData['OUT_DOC_FILENAME'])) {
+ $oOutputDocument->setOutDocFilename($aData['OUT_DOC_FILENAME']);
+ }
+
+ if (isset($aData['OUT_DOC_TEMPLATE'])) {
+ $oOutputDocument->setOutDocTemplate($aData['OUT_DOC_TEMPLATE']);
+ }
+
+ $iResult = $oOutputDocument->save();
+ $oConnection->commit();
+
+ 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);
}
- $iResult = $oOutputDocument->save();
- $oConnection->commit();
- return $aData['OUT_DOC_UID'];
- }
- else {
- $sMessage = '';
- $aValidationFailures = $oOutputDocument->getValidationFailures();
- foreach($aValidationFailures as $oValidationFailure) {
- $sMessage .= $oValidationFailure->getMessage() . '
';
+ }
+
+ /**
+ * 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();
+
+ return $iResult;
+ } else {
+ throw (new Exception('This row doesn\'t exist!'));
+ }
+ } catch (Exception $oError) {
+ $oConnection->rollback();
+
+ throw ($oError);
}
- 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->setOutDocTitle($aData['OUT_DOC_TITLE']);
- }
- if (isset($aData['OUT_DOC_DESCRIPTION']))
- {
- $oOutputDocument->setOutDocDescription($aData['OUT_DOC_DESCRIPTION']);
- }
- if (isset($aData['OUT_DOC_FILENAME']))
- {
- $oOutputDocument->setOutDocFilename($aData['OUT_DOC_FILENAME']);
- }
- if (isset($aData['OUT_DOC_TEMPLATE']))
- {
- $oOutputDocument->setOutDocTemplate($aData['OUT_DOC_TEMPLATE']);
- }
- $iResult = $oOutputDocument->save();
- $oConnection->commit();
- 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();
- 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 getOutDocTitle()
- {
- 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 setOutDocTitle($sValue)
- {
- if ($sValue !== null && !is_string($sValue)) {
- $sValue = (string)$sValue;
- }
- if ($this->out_doc_title !== $sValue || $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 getOutDocDescription()
- {
- 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 setOutDocDescription($sValue)
- {
- if ($sValue !== null && !is_string($sValue)) {
- $sValue = (string)$sValue;
- }
- if ($this->out_doc_description !== $sValue || $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 getOutDocFilename()
- {
- 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 setOutDocFilename($sValue)
- {
- if ($sValue !== null && !is_string($sValue)) {
- $sValue = (string)$sValue;
- }
- if ($this->out_doc_filename !== $sValue || $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 getOutDocTemplate()
- {
- 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 setOutDocTemplate($sValue)
- {
- if ($sValue !== null && !is_string($sValue)) {
- $sValue = (string)$sValue;
- }
- if ($this->out_doc_template !== $sValue || $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 $sUID
- * @param array $aFields
- * @param string $sPath
- * @return variant
- */
- public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array()) {
- if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
- $sContent = G::unhtmlentities($sContent);
- $strContentAux = str_replace(array("\n", "\r", "\t"), array(null, null, null), $sContent);
-
- $iOcurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $strContentAux, $arrayMatch1, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
-
- if ($iOcurrences) {
- $arrayGrid = array();
-
- for ($i = 0; $i <= $iOcurrences - 1; $i++) {
- $arrayGrid[] = $arrayMatch1[2][$i][0];
+ /**
+ * Get the [out_doc_title] column value.
+ * @return string
+ */
+ public function getOutDocTitle()
+ {
+ 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);
+ }
}
- $arrayGrid = array_unique($arrayGrid);
+ return $this->out_doc_title;
+ }
- foreach ($arrayGrid as $index => $value) {
- $grdName = $value;
+ /**
+ * Set the [out_doc_title] column value.
+ *
+ * @param string $sValue new value
+ * @return void
+ */
+ public function setOutDocTitle($sValue)
+ {
+ if ($sValue !== null && !is_string($sValue)) {
+ $sValue = (string)$sValue;
+ }
- $strContentAux1 = $strContentAux;
- $strContentAux = null;
+ if ($this->out_doc_title !== $sValue || $sValue === '') {
+ try {
+ $this->out_doc_title = $sValue;
- while (preg_match("/^(.*)@>" . $grdName . "(.*)@<" . $grdName . "(.*)$/", $strContentAux1, $arrayMatch2)) {
- $strData = null;
+ $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 = '';
- if (isset($aFields[$grdName]) && is_array($aFields[$grdName])) {
- foreach ($aFields[$grdName] as $aRow) {
- foreach ($aRow as $sKey => $vValue) {
- if (!is_array($vValue)) {
- $aRow[$sKey] = nl2br($aRow[$sKey]);
+ throw ($oError);
+ }
+ }
+ }
+
+ /**
+ * Get the [out_doc_comment] column value.
+ * @return string
+ */
+ public function getOutDocDescription()
+ {
+ 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 setOutDocDescription($sValue)
+ {
+ if ($sValue !== null && !is_string($sValue)) {
+ $sValue = (string)$sValue;
+ }
+
+ if ($this->out_doc_description !== $sValue || $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 getOutDocFilename()
+ {
+ 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 setOutDocFilename($sValue)
+ {
+ if ($sValue !== null && !is_string($sValue)) {
+ $sValue = (string)$sValue;
+ }
+
+ if ($this->out_doc_filename !== $sValue || $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 getOutDocTemplate()
+ {
+ 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 setOutDocTemplate($sValue)
+ {
+ if ($sValue !== null && !is_string($sValue)) {
+ $sValue = (string)$sValue;
+ }
+
+ if ($this->out_doc_template !== $sValue || $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 $sUID
+ * @param array $aFields
+ * @param string $sPath
+ * @return variant
+ */
+ public function generate(
+ $sUID,
+ $aFields,
+ $sPath,
+ $sFilename,
+ $sContent,
+ $sLandscape=false,
+ $sTypeDocToGener='BOTH',
+ $aProperties=array()
+ ) {
+ if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
+ $sContent = G::unhtmlentities($sContent);
+ $strContentAux = str_replace(array("\n", "\r", "\t"), array(null, null, null), $sContent);
+
+ $iOcurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $strContentAux, $arrayMatch1, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
+
+ if ($iOcurrences) {
+ $arrayGrid = array();
+
+ for ($i = 0; $i <= $iOcurrences - 1; $i++) {
+ $arrayGrid[] = $arrayMatch1[2][$i][0];
+ }
+
+ $arrayGrid = array_unique($arrayGrid);
+
+ foreach ($arrayGrid as $index => $value) {
+ $grdName = $value;
+
+ $strContentAux1 = $strContentAux;
+ $strContentAux = null;
+
+ $ereg = "/^(.*)@>" . $grdName . "(.*)@<" . $grdName . "(.*)$/";
+
+ while (preg_match($ereg, $strContentAux1, $arrayMatch2)) {
+ $strData = null;
+
+ if (isset($aFields[$grdName]) && is_array($aFields[$grdName])) {
+ foreach ($aFields[$grdName] as $aRow) {
+ foreach ($aRow as $sKey => $vValue) {
+ if (!is_array($vValue)) {
+ $aRow[$sKey] = nl2br($aRow[$sKey]);
+ }
+ }
+
+ $strData = $strData . G::replaceDataField($arrayMatch2[2], $aRow);
}
}
- $strData = $strData . G::replaceDataField($arrayMatch2[2], $aRow);
+ $strContentAux1 = $arrayMatch2[1];
+ $strContentAux = $strData . $arrayMatch2[3] . $strContentAux;
}
- }
- $strContentAux1 = $arrayMatch2[1];
- $strContentAux = $strData . $arrayMatch2[3] . $strContentAux;
+ $strContentAux = $strContentAux1 . $strContentAux;
+ }
}
- $strContentAux = $strContentAux1 . $strContentAux;
+ $sContent = $strContentAux;
+
+ foreach ($aFields as $sKey => $vValue) {
+ if (!is_array($vValue)) {
+ $aFields[$sKey] = nl2br($aFields[$sKey]);
+ }
+ }
+
+ $sContent = G::replaceDataField($sContent, $aFields);
+
+ G::verifyPath($sPath, true);
+
+ //Start - Create .doc
+ $oFile = fopen($sPath . $sFilename . '.doc', 'wb');
+
+ $size = array();
+ $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["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($aProperties['media'])) {
+ $aProperties['media'] = 'Letter';
+ }
+
+ if ($sLandscape) {
+ $media = $sizeLandscape[$aProperties['media']];
+ } else {
+ $media = $size[$aProperties['media']];
+ }
+
+ $marginLeft = '15';
+
+ if (isset($aProperties['margins']['left'])) {
+ $marginLeft = $aProperties['margins']['left'];
+ }
+
+ $marginRight = '15';
+
+ if (isset($aProperties['margins']['right'])) {
+ $marginRight = $aProperties['margins']['right'];
+ }
+
+ $marginTop = '15';
+
+ if (isset($aProperties['margins']['top'])) {
+ $marginTop = $aProperties['margins']['top'];
+ }
+
+ $marginBottom = '15';
+
+ if (isset($aProperties['margins']['bottom'])) {
+ $marginBottom = $aProperties['margins']['bottom'];
+ }
+
+ fwrite($oFile, '
+