diff --git a/Rakefile b/Rakefile index 6794d1e2e..a43a131b5 100644 --- a/Rakefile +++ b/Rakefile @@ -192,7 +192,7 @@ def buildPmdynaform(homeDir, targetDir, mode) template += s end - htmlTemplates=["cases_Step_Pmdynaform.html","cases_Step_Pmdynaform_Preview.html","cases_Step_Pmdynaform_View.html"] + htmlTemplates=["cases_Step_Pmdynaform.html","cases_Step_Pmdynaform_Preview.html","cases_Step_Pmdynaform_View.html","WebEntry_Pmdynaform.html"] htmlTemplates.each do |htmlTemplate| FileUtils.cp("#{Dir.pwd}/workflow/engine/templates/cases/#{htmlTemplate}", "#{pmdynaformDir}/build/#{htmlTemplate}") diff --git a/workflow/engine/classes/class.pmDynaform.php b/workflow/engine/classes/class.pmDynaform.php index d45c6f9d1..8b1b05123 100644 --- a/workflow/engine/classes/class.pmDynaform.php +++ b/workflow/engine/classes/class.pmDynaform.php @@ -17,67 +17,77 @@ class pmDynaform public $items = array(); public $data = array(); public $variables = array(); + public $arrayFieldRequired = array(); - public function __construct($dyn_uid, $app_data) - { + public function __construct($dyn_uid, $app_data = array()) + { $this->dyn_uid = $dyn_uid; $this->app_data = $app_data; $this->getDynaform(); - + //items $dynContent = G::json_decode($this->record["DYN_CONTENT"]); if (isset($dynContent->items)) { - $this->items = $dynContent->items[0]->items; - } - - //data - $cases = new \ProcessMaker\BusinessModel\Cases(); - $this->data = $cases->getCaseVariables($app_data["APPLICATION"]); - - //variables - $this->variables = array(); - - $a = new Criteria("workflow"); - $a->addSelectColumn(ProcessVariablesPeer::VAR_NAME); - $a->addSelectColumn(ProcessVariablesPeer::VAR_SQL); - $a->addSelectColumn(ProcessVariablesPeer::VAR_ACCEPTED_VALUES); - $a->addSelectColumn(ProcessVariablesPeer::VAR_DBCONNECTION); - - $c3 = $a->getNewCriterion(ProcessVariablesPeer::VAR_ACCEPTED_VALUES, "", Criteria::ALT_NOT_EQUAL); - $c2 = $a->getNewCriterion(ProcessVariablesPeer::VAR_ACCEPTED_VALUES, "[]", Criteria::ALT_NOT_EQUAL); - $c2->addAnd($c3); - - $c4 = $a->getNewCriterion(ProcessVariablesPeer::PRJ_UID, $this->app_data["PROCESS"], Criteria::EQUAL); - - $c1 = $a->getNewCriterion(ProcessVariablesPeer::VAR_SQL, "", Criteria::ALT_NOT_EQUAL); - $c1->addOr($c2); - $c1->addAnd($c4); - - $a->add($c1); - - $ds = ProcessPeer::doSelectRS($a); - $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC); - - while ($ds->next()) { - $row = $ds->getRow(); - //options - $rows2 = json_decode($row["VAR_ACCEPTED_VALUES"]); - $n = count($rows2); - for ($i = 0; $i < $n; $i++) { - $rows2[$i] = array($rows2[$i]->keyValue, $rows2[$i]->value); - } - //query - $arrayVariable = array(); - if ($row["VAR_DBCONNECTION"] !== "none") { - $cnn = Propel::getConnection($row["VAR_DBCONNECTION"]); - $stmt = $cnn->createStatement(); - $rs = $stmt->executeQuery(\G::replaceDataField($row["VAR_SQL"], $arrayVariable), \ResultSet::FETCHMODE_NUM); - while ($rs->next()) { - array_push($rows2, $rs->getRow()); + $this->items = $dynContent->items[0]->items; + for($i=0; $iitems); $i++){ + for($j=0; $jitems[$i]); $j++){ + if($this->items[$i][$j]->required == 1){ + array_push($this->arrayFieldRequired, $this->items[$i][$j]->name); + } } - } - $this->variables[$row["VAR_NAME"]] = $rows2; + } } + if(!empty($app_data)){ + //data + $cases = new \ProcessMaker\BusinessModel\Cases(); + $this->data = $cases->getCaseVariables($app_data["APPLICATION"]); + + //variables + $this->variables = array(); + + $a = new Criteria("workflow"); + $a->addSelectColumn(ProcessVariablesPeer::VAR_NAME); + $a->addSelectColumn(ProcessVariablesPeer::VAR_SQL); + $a->addSelectColumn(ProcessVariablesPeer::VAR_ACCEPTED_VALUES); + $a->addSelectColumn(ProcessVariablesPeer::VAR_DBCONNECTION); + + $c3 = $a->getNewCriterion(ProcessVariablesPeer::VAR_ACCEPTED_VALUES, "", Criteria::ALT_NOT_EQUAL); + $c2 = $a->getNewCriterion(ProcessVariablesPeer::VAR_ACCEPTED_VALUES, "[]", Criteria::ALT_NOT_EQUAL); + $c2->addAnd($c3); + + $c4 = $a->getNewCriterion(ProcessVariablesPeer::PRJ_UID, $this->app_data["PROCESS"], Criteria::EQUAL); + + $c1 = $a->getNewCriterion(ProcessVariablesPeer::VAR_SQL, "", Criteria::ALT_NOT_EQUAL); + $c1->addOr($c2); + $c1->addAnd($c4); + + $a->add($c1); + + $ds = ProcessPeer::doSelectRS($a); + $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC); + + while ($ds->next()) { + $row = $ds->getRow(); + //options + $rows2 = G::json_decode($row["VAR_ACCEPTED_VALUES"]); + $n = count($rows2); + for ($i = 0; $i < $n; $i++) { + $rows2[$i] = array($rows2[$i]->keyValue, $rows2[$i]->value); + } + //query + $arrayVariable = array(); + if ($row["VAR_DBCONNECTION"] !== "none") { + $cnn = Propel::getConnection($row["VAR_DBCONNECTION"]); + $stmt = $cnn->createStatement(); + $rs = $stmt->executeQuery(\G::replaceDataField($row["VAR_SQL"], $arrayVariable), \ResultSet::FETCHMODE_NUM); + while ($rs->next()) { + array_push($rows2, $rs->getRow()); + } + } + $this->variables[$row["VAR_NAME"]] = $rows2; + } + } + } public function getDynaform() @@ -94,7 +104,7 @@ class pmDynaform $ds = ProcessPeer::doSelectRS($a); $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC); $ds->next(); - $row = $ds->getRow(); + $row = $ds->getRow(); $this->record = isset($row) ? $row : null; return $this->record; @@ -238,7 +248,34 @@ class pmDynaform $file = str_replace("{PRJ_UID}", $this->app_data["PROCESS"], $file); $file = str_replace("{STEP_MODE}", $step_mode, $file); $file = str_replace("{WORKSPACE}", $this->app_data["SYS_SYS"], $file); - $file = str_replace("{credentials}", json_encode($clientToken), $file); + $file = str_replace("{PORT}", $_SERVER["SERVER_PORT"] , $file); + $file = str_replace("{credentials}", G::json_encode($clientToken), $file); + echo $file; + exit(); + } + + public function printWebEntry($filename) + { + ob_clean(); + $a = $this->clientToken(); + $clientToken = array( + "accessToken" => $a["access_token"], + "expiresIn" => $a["expires_in"], + "tokenType" => $a["token_type"], + "scope" => $a["scope"], + "refreshToken" => $a["refresh_token"], + "clientId" => $a["client_id"], + "clientSecret" => $a["client_secret"] + ); + $file = file_get_contents(PATH_HOME . 'public_html/lib/pmdynaform/build/WebEntry_Pmdynaform.html'); + $file = str_replace("{JSON_DATA}", $this->record["DYN_CONTENT"], $file); + $file = str_replace("{DYN_UID}", $this->dyn_uid, $file); + $file = str_replace("{PRJ_UID}",$this->record["PRO_UID"], $file); + $file = str_replace("{WORKSPACE}", SYS_SYS, $file); + $file = str_replace("{FILEPOST}", $filename, $file); + $file = str_replace("{PORT}", $_SERVER["SERVER_PORT"] , $file); + $file = str_replace("{credentials}", G::json_encode($clientToken), $file); + $file = str_replace("{FIELDSREQUIRED}", G::json_encode($this->arrayFieldRequired), $file); echo $file; exit(); } diff --git a/workflow/engine/classes/model/CaseScheduler.php b/workflow/engine/classes/model/CaseScheduler.php index 5da738c85..05ec7dda7 100755 --- a/workflow/engine/classes/model/CaseScheduler.php +++ b/workflow/engine/classes/model/CaseScheduler.php @@ -53,6 +53,28 @@ class CaseScheduler extends BaseCaseScheduler throw ($e); } $con->commit(); + + //Add Audit Log + switch ($aData['SCH_OPTION']) { + case '1': + $perform = 'Daily'; + break; + case '2': + $perform = 'Weekly'; + break; + case '3': + $perform = 'Monthly'; + break; + case '4': + $perform = 'One time only'; + break; + case '5': + $perform = 'Every'; + break; + + } + G::auditLog("CreateCaseScheduler", "Scheduler Name: ".$aData['SCH_NAME'].", Task: ".$aData['TAS_UID'].", Perform this task: ".$perform.", Start Date: ".$aData['SCH_START_DATE'].", End Date: ".$aData['SCH_END_DATE'].", Execution time : ".$aData['SCH_START_TIME']); + return $result; } catch (Exception $e) { $con->rollback(); @@ -70,6 +92,27 @@ class CaseScheduler extends BaseCaseScheduler if ($this->validate()) { $result = $this->save(); $con->commit(); + + //Add Audit Log + switch ($fields['SCH_OPTION']){ + case '1': + $perform = 'Daily'; + break; + case '2': + $perform = 'Weekly'; + break; + case '3': + $perform = 'Monthly'; + break; + case '4': + $perform = 'One time only'; + break; + case '5': + $perform = 'Every'; + break; + } + G::auditLog("UpdateCaseScheduler", "Scheduler Name: ".$fields['SCH_NAME'].", Task: ".$fields['TAS_UID'].", Perform this task: ".$perform.", Start Date: ".$fields['SCH_START_DATE'].", End Date: ".$fields['SCH_END_DATE'].", Execution time : ".$fields['SCH_START_TIME']); + return $result; } else { $con->rollback(); @@ -87,8 +130,12 @@ class CaseScheduler extends BaseCaseScheduler try { $oCaseScheduler = CaseSchedulerPeer::retrieveByPK( $SchUid ); if (! is_null( $oCaseScheduler )) { + $fields = $this->Load( $SchUid ); $iResult = $oCaseScheduler->delete(); $con->commit(); + //Add Audit Log + G::auditLog("DeleteCaseScheduler", "Scheduler Name: ".$fields['SCH_NAME'].", Task: ".$fields['TAS_UID']); + return $iResult; } else { throw (new Exception( 'This row doesn\'t exist!' )); diff --git a/workflow/engine/classes/model/DbSource.php b/workflow/engine/classes/model/DbSource.php index 35acb7d12..d6766fbcf 100755 --- a/workflow/engine/classes/model/DbSource.php +++ b/workflow/engine/classes/model/DbSource.php @@ -141,6 +141,9 @@ class DbSource extends BaseDbSource if ($this->validate()) { $result = $this->save(); $con->commit(); + //Add Audit Log + G::auditLog("UpdateDatabaseConnection", "Connection Uid: ".$fields['DBS_UID'].", Connection Engine: ".$fields['DBS_TYPE'].", Connection Encode: ".$fields['DBS_ENCODE'].", Connection Server: ".$fields['DBS_SERVER'].", Connection Database: ".$fields['DBS_DATABASE_NAME'].", Connection Port: ".$fields['DBS_PORT']); + return $result; } else { $con->rollback(); @@ -156,6 +159,7 @@ class DbSource extends BaseDbSource { $con = Propel::getConnection(DbSourcePeer::DATABASE_NAME); try { + $fields = $this->load($DbsUid, $ProUID); $con->begin(); $this->setDbsUid($DbsUid); $this->setProUid($ProUID); @@ -167,6 +171,9 @@ class DbSource extends BaseDbSource } $result = $this->delete(); $con->commit(); + //Add Audit Log + G::auditLog("DeleteDatabaseConnection", "Connection Uid: ".$DbsUid.", Connection Engine: ".$fields['DBS_TYPE'].", Connection Database: ".$fields['DBS_DATABASE_NAME']); + return $result; } catch (exception $e) { $con->rollback(); @@ -196,6 +203,9 @@ class DbSource extends BaseDbSource throw ($e); } $con->commit(); + //Add Audit Log + G::auditLog("CreateDatabaseConnection", "Connection Uid: ".$aData['DBS_UID'].", Connection Engine: ".$aData['DBS_TYPE'].", Connection Encode: ".$aData['DBS_ENCODE'].", Connection Server: ".$aData['DBS_SERVER'].", Connection Database: ".$aData['DBS_DATABASE_NAME'].", Connection Port: ".$aData['DBS_PORT']); + return $this->getDbsUid(); } catch (exception $e) { $con->rollback(); diff --git a/workflow/engine/classes/model/InputDocument.php b/workflow/engine/classes/model/InputDocument.php index 23615c7f6..b19036ad8 100755 --- a/workflow/engine/classes/model/InputDocument.php +++ b/workflow/engine/classes/model/InputDocument.php @@ -126,6 +126,34 @@ class InputDocument extends BaseInputDocument } $iResult = $oInputDocument->save(); $oConnection->commit(); + //Add Audit Log + switch ($aData['INP_DOC_FORM_NEEDED']){ + case 'VIRTUAL': + $docType = 'Digital'; + break; + case 'REAL': + $docType = 'Printed'; + break; + case 'VREAL': + $docType = 'Digital/Printed'; + break; + } + if(isset($aData['INP_DOC_VERSIONING']) && $aData['INP_DOC_VERSIONING'] == 1){ + $enableVersion = 'Yes'; + }else{ + $enableVersion = 'No'; + } + $description = "Input Document Title: ".$aData['INP_DOC_TITLE'].", Input Document Uid: ".$aData['INP_DOC_UID'].", Document Type: ".$docType; + if(!empty($aData['INP_DOC_DESCRIPTION'])){ + $description .= ", Description: ".$aData['INP_DOC_DESCRIPTION']; + } + if(!empty($aData['INP_DOC_DESTINATION_PATH'])){ + $description .= ", Destination Path: ".$aData['INP_DOC_DESTINATION_PATH']; + } + $inputDocMaxFileSize = $aData['INP_DOC_MAX_FILESIZE']? $aData['INP_DOC_MAX_FILESIZE'].' '.$aData['INP_DOC_MAX_FILESIZE_UNIT'] : "256 MB"; + $description .= ", Extensions: ".$aData['INP_DOC_TYPE_FILE'].", Maximum Input Document file size: ".$inputDocMaxFileSize; + G::auditLog("CreateInputDocument", $description); + return $aData['INP_DOC_UID']; } else { $sMessage = ''; @@ -165,6 +193,34 @@ class InputDocument extends BaseInputDocument } $iResult = $oInputDocument->save(); $oConnection->commit(); + //Add Audit Log + switch ($aData['INP_DOC_FORM_NEEDED']){ + case 'VIRTUAL': + $docType = 'Digital'; + break; + case 'REAL': + $docType = 'Printed'; + break; + case 'VREAL': + $docType = 'Digital/Printed'; + break; + } + if(isset($aData['INP_DOC_VERSIONING']) && $aData['INP_DOC_VERSIONING'] == 1){ + $enableVersion = 'Yes'; + }else{ + $enableVersion = 'No'; + } + $description = "Input Document Title: ".$aData['INP_DOC_TITLE'].", Input Document Uid: ".$aData['INP_DOC_UID'].", Document Type: ".$docType; + if(!empty($aData['INP_DOC_DESCRIPTION'])){ + $description .= ", Description: ".$aData['INP_DOC_DESCRIPTION']; + } + if(!empty($aData['INP_DOC_DESTINATION_PATH'])){ + $description .= ", Destination Path: ".$aData['INP_DOC_DESTINATION_PATH']; + } + $inputDocMaxFileSize = $aData['INP_DOC_MAX_FILESIZE']? $aData['INP_DOC_MAX_FILESIZE'].' '.$aData['INP_DOC_MAX_FILESIZE_UNIT'] : "256 MB"; + $description .= ", Extensions: ".$aData['INP_DOC_TYPE_FILE'].", Maximum Input Document file size: ".$inputDocMaxFileSize; + G::auditLog("UpdateInputDocument", $description); + return $iResult; } else { $sMessage = ''; @@ -196,11 +252,18 @@ class InputDocument extends BaseInputDocument try { $oInputDocument = InputDocumentPeer::retrieveByPK( $sInpDocUid ); if (! is_null( $oInputDocument )) { + $nameInput = $this->getInpDocTitle(); + $descInput = $this->getInpDocDescription(); $oConnection->begin(); Content::removeContent( 'INP_DOC_TITLE', '', $oInputDocument->getInpDocUid() ); Content::removeContent( 'INP_DOC_DESCRIPTION', '', $oInputDocument->getInpDocUid() ); $iResult = $oInputDocument->delete(); $oConnection->commit(); + //Add Audit Log + $nameInput = $this->getInpDocTitle(); + $descInput = $this->getInpDocDescription(); + G::auditLog("DeleteInputDocument", "Input Document Name: ".$nameInput.", Input Document Uid: ".$sInpDocUid.", Description: ".$descInput); + return $iResult; } else { throw (new Exception( 'This row doesn\'t exist!' )); diff --git a/workflow/engine/classes/model/OutputDocument.php b/workflow/engine/classes/model/OutputDocument.php index bfd361304..07e2d227f 100755 --- a/workflow/engine/classes/model/OutputDocument.php +++ b/workflow/engine/classes/model/OutputDocument.php @@ -1,1127 +1,1188 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -//require_once ("classes/model/om/BaseOutputDocument.php"); -//require_once ("classes/model/Content.php"); - -/** - * Skeleton subclass for representing a row from the 'OUTPUT_DOCUMENT' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package workflow.engine.classes.model - */ -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_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_template = ''; - - public 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; - } 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['PRO_UID'] = $oOutputDocument->getProUid(); - $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); - } - } - - /** - * 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); - } - } - - /** - * 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::replaceDataGridField($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, ' - - - - - - - - - - - -
'); - - fwrite($oFile, $sContent); - fwrite($oFile, "\n
\n\n"); - fclose($oFile); - /* End - Create .doc */ - - if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') { - $oFile = fopen($sPath . $sFilename . '.html', 'wb'); - fwrite($oFile, $sContent); - fclose($oFile); - /* Start - Create .pdf */ - if (isset($aProperties['report_generator'])) { - switch ($aProperties['report_generator']) { - case 'TCPDF': - $this->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties); - break; - case 'HTML2PDF': - default: - $this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties); - break; - } - } else { - $this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties); - } - } - //end if $sTypeDocToGener - /* End - Create .pdf */ - } else { - return PEAR::raiseError( - null, G_ERROR_USER_UID, null, null, 'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!', 'G_Error', true - ); - } - } - - public function generateHtml2pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array()) - { - - // define("MAX_FREE_FRACTION", 1); - define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/'); - G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true); - - require_once(PATH_THIRDPARTY . 'html2pdf/html2pdf.class.php'); - - // define Save file - $sOutput = 2; - $sOrientation = ($sLandscape == false) ? 'P' : 'L'; - $sLang = (defined('SYS_LANG')) ? SYS_LANG : 'en'; - $sMedia = $aProperties['media']; - // margin define - define("MINIMAL_MARGIN", 15); - $marges = array(MINIMAL_MARGIN, MINIMAL_MARGIN, MINIMAL_MARGIN, MINIMAL_MARGIN); - if (isset($aProperties['margins'])) { - // Default marges (left, top, right, bottom) - $margins = $aProperties['margins']; - $margins['left'] = ($margins['left'] > 0) ? $margins['left'] : MINIMAL_MARGIN; - $margins['top'] = ($margins['top'] > 0) ? $margins['top'] : MINIMAL_MARGIN; - $margins['right'] = ($margins['right'] > 0) ? $margins['right'] : MINIMAL_MARGIN; - $margins['bottom'] = ($margins['bottom'] > 0) ? $margins['bottom'] : MINIMAL_MARGIN; - $marges = array($margins['left'], $margins['top'], $margins['right'], $margins['bottom']); - } - - $html2pdf = new HTML2PDF($sOrientation, $sMedia, $sLang, true, 'UTF-8', $marges); - - $html2pdf->pdf->SetAuthor($aFields['USR_USERNAME']); - $html2pdf->pdf->SetTitle('Processmaker'); - $html2pdf->pdf->SetSubject($sFilename); - $html2pdf->pdf->SetCompression(true); - - //$html2pdf->pdf->SetKeywords('HTML2PDF, TCPDF, processmaker'); - - if (isset($aProperties['pdfSecurity'])) { - $pdfSecurity = $aProperties['pdfSecurity']; - $userPass = G::decrypt($pdfSecurity['openPassword'], $sUID); - $ownerPass = ($pdfSecurity['ownerPassword'] != '') ? G::decrypt($pdfSecurity['ownerPassword'], $sUID) : null; - $permissions = explode("|", $pdfSecurity['permissions']); - $html2pdf->pdf->SetProtection($permissions, $userPass, $ownerPass); - } - - $html2pdf->setTestTdInOnePage(false); - $html2pdf->setTestIsImage(false); - $html2pdf->setTestIsDeprecated(false); - - $html2pdf->writeHTML($html2pdf->getHtmlFromPage($sContent)); - - switch ($sOutput) { - case 0: - // Vrew browser - $html2pdf->Output($sPath . $sFilename . '.pdf', 'I'); - break; - case 1: - // Donwnload - $html2pdf->Output($sPath . $sFilename . '.pdf', 'D'); - break; - case 2: - // Save file - $html2pdf->Output($sPath . $sFilename . '.pdf', 'F'); - break; - } - - copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); - - copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf'); - unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf'); - unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); - } - - public function generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array()) - { - require_once (PATH_THIRDPARTY . "tcpdf" . PATH_SEP . "config" . PATH_SEP . "lang" . PATH_SEP . "eng.php"); - require_once (PATH_THIRDPARTY . "tcpdf" . PATH_SEP . "tcpdf.php"); - - $nrt = array("\n", "\r", "\t"); - $nrthtml = array("(n /)", "(r /)", "(t /)"); - - $strContentAux = str_replace($nrt, $nrthtml, $sContent); - $sContent = null; - - while (preg_match("/^(.*)]*)>(.*)$/i", $strContentAux, $arrayMatch)) { - $str = trim($arrayMatch[2]); - $strAttribute = null; - - if (!empty($str)) { - $strAux = $str; - $str = null; - - while (preg_match("/^(.*)([\"'].*[\"'])(.*)$/", $strAux, $arrayMatch2)) { - $strAux = $arrayMatch2[1]; - $str = str_replace(" ", "__SPACE__", $arrayMatch2[2]) . $arrayMatch2[3] . $str; - } - - $str = $strAux . $str; - - //Get attributes - $strStyle = null; - $array = explode(" ", $str); - - foreach ($array as $value) { - $arrayAux = explode("=", $value); - - if (isset($arrayAux[1])) { - $a = trim($arrayAux[0]); - $v = trim(str_replace(array("__SPACE__", "\"", "'"), array(" ", null, null), $arrayAux[1])); - - switch (strtolower($a)) { - case "color": - $strStyle = $strStyle . "color: $v;"; - break; - case "face": - $strStyle = $strStyle . "font-family: $v;"; - break; - case "size": - $arrayPt = array(0, 8, 10, 12, 14, 18, 24, 36); - $strStyle = $strStyle . "font-size: " . $arrayPt[intval($v)] . "pt;"; - break; - case "style": - $strStyle = $strStyle . "$v;"; - break; - default: - $strAttribute = $strAttribute . " $a=\"$v\""; - break; - } - } - } - - if ($strStyle != null) { - $strAttribute = $strAttribute . " style=\"$strStyle\""; - } - } - - $strContentAux = $arrayMatch[1]; - $sContent = "" . $arrayMatch[3] . $sContent; - } - - $sContent = $strContentAux . $sContent; - - $sContent = str_ireplace("", "", $sContent); - - $sContent = str_replace($nrthtml, $nrt, $sContent); - - $sContent = str_replace("margin-left", "text-indent", $sContent); - - // define Save file - $sOutput = 2; - $sOrientation = ($sLandscape == false) ? PDF_PAGE_ORIENTATION : 'L'; - $sMedia = (isset($aProperties['media'])) ? $aProperties['media'] : PDF_PAGE_FORMAT; - $sLang = (defined('SYS_LANG')) ? SYS_LANG : 'en'; - - // create new PDF document - $pdf = new TCPDF($sOrientation, PDF_UNIT, $sMedia, true, 'UTF-8', false); - - // set document information - $pdf->SetCreator(PDF_CREATOR); - $pdf->SetAuthor($aFields['USR_USERNAME']); - $pdf->SetTitle('Processmaker'); - $pdf->SetSubject($sFilename); - $pdf->SetCompression(true); - - $margins = $aProperties['margins']; - $margins["left"] = ($margins["left"] >= 0) ? $margins["left"] : PDF_MARGIN_LEFT; - $margins["top"] = ($margins["top"] >= 0) ? $margins["top"] : PDF_MARGIN_TOP; - $margins["right"] = ($margins["right"] >= 0) ? $margins["right"] : PDF_MARGIN_RIGHT; - $margins["bottom"] = ($margins["bottom"] >= 0) ? $margins["bottom"] : PDF_MARGIN_BOTTOM; - - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - $pdf->SetLeftMargin($margins['left']); - $pdf->SetTopMargin($margins['top']); - $pdf->SetRightMargin($margins['right']); - $pdf->SetAutoPageBreak(true, $margins['bottom']); - - $oServerConf = &serverConf::getSingleton(); - - // set some language dependent data: - $lg = array(); - $lg['a_meta_charset'] = 'UTF-8'; - $lg['a_meta_dir'] = ($oServerConf->isRtl($sLang)) ? 'rtl' : 'ltr'; - $lg['a_meta_language'] = $sLang; - $lg['w_page'] = 'page'; - - //set some language-dependent strings - $pdf->setLanguageArray($lg); - - if (isset($aProperties['pdfSecurity'])) { - $tcpdfPermissions = array('print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'); - $pdfSecurity = $aProperties['pdfSecurity']; - $userPass = G::decrypt($pdfSecurity['openPassword'], $sUID); - $ownerPass = ($pdfSecurity['ownerPassword'] != '') ? G::decrypt($pdfSecurity['ownerPassword'], $sUID) : null; - $permissions = explode("|", $pdfSecurity['permissions']); - $permissions = array_diff($tcpdfPermissions, $permissions); - $pdf->SetProtection($permissions, $userPass, $ownerPass); - } - // --------------------------------------------------------- - // set default font subsetting mode - $pdf->setFontSubsetting(true); - - // Set font - // dejavusans is a UTF-8 Unicode font, if you only need to - // print standard ASCII chars, you can use core fonts like - // helvetica or times to reduce file size. - //$pdf->SetFont('dejavusans', '', 14, '', true); - // Detect chinese, japanese, thai - if (preg_match('/[\x{30FF}\x{3040}-\x{309F}\x{4E00}-\x{9FFF}\x{0E00}-\x{0E7F}]/u', $sContent, $matches)) { - $fileArialunittf = PATH_THIRDPARTY . "tcpdf" . PATH_SEP . "fonts" . PATH_SEP . "arialuni.ttf"; - - $pdf->SetFont((!file_exists($fileArialunittf))? "kozminproregular" : $pdf->addTTFfont($fileArialunittf, "TrueTypeUnicode", "", 32)); - } - - // Add a page - // This method has several options, check the source code documentation for more information. - $pdf->AddPage(); - - // set text shadow effect - //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); - // Print text using writeHTMLCell() - // $pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true); - if (mb_detect_encoding($sContent) == 'UTF-8') { - $sContent = mb_convert_encoding($sContent, 'HTML-ENTITIES', 'UTF-8'); - } - $doc = new DOMDocument('1.0', 'UTF-8'); - if ($sContent != '') { - $doc->loadHtml($sContent); - } - $pdf->writeHTML($doc->saveXML(), false, false, false, false, ''); - // --------------------------------------------------------- - // Close and output PDF document - // This method has several options, check the source code documentation for more information. - //$pdf->Output('example_00.pdf', 'I'); - //$pdf->Output('/home/hector/processmaker/example_00.pdf', 'D'); - switch ($sOutput) { - case 0: - // Vrew browser - $pdf->Output($sPath . $sFilename . '.pdf', 'I'); - break; - case 1: - // Donwnload - $pdf->Output($sPath . $sFilename . '.pdf', 'D'); - break; - case 2: - // Save file - $pdf->Output($sPath . $sFilename . '.pdf', 'F'); - break; - } - } - - public function generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array()) - { - - define("MAX_FREE_FRACTION", 1); - define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/'); - G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true); - require_once (PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php'); - require_once (PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php'); - - parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config'); - - $GLOBALS['g_config'] = array( - 'cssmedia' => 'screen', - 'media' => 'Letter', - 'scalepoints' => false, - 'renderimages' => true, - 'renderfields' => true, - 'renderforms' => false, - 'pslevel' => 3, - 'renderlinks' => true, - 'pagewidth' => 800, - 'landscape' => $sLandscape, - 'method' => 'fpdf', - 'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15,), - 'encoding' => (version_compare(PHP_VERSION, '5.4.0', '<') ? '' : 'utf-8'), - 'ps2pdf' => false, - 'compress' => true, - 'output' => 2, - 'pdfversion' => '1.3', - 'transparency_workaround' => false, - 'imagequality_workaround' => false, - 'draw_page_border' => isset($_REQUEST['pageborder']), - 'debugbox' => false, - 'html2xhtml' => true, - 'mode' => 'html', - 'smartpagebreak' => true - ); - - $GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties); - $g_media = Media::predefined($GLOBALS['g_config']['media']); - $g_media->set_landscape($GLOBALS['g_config']['landscape']); - $g_media->set_margins($GLOBALS['g_config']['margins']); - $g_media->set_pixels($GLOBALS['g_config']['pagewidth']); - - - if (isset($GLOBALS['g_config']['pdfSecurity'])) { - if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) && - $GLOBALS['g_config']['pdfSecurity']['openPassword'] != "" - ) { - $GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt( - $GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID - ); - } - - if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) && - $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != "" - ) { - $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt( - $GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID - ); - } - - $g_media->set_security($GLOBALS['g_config']['pdfSecurity']); - - require_once (HTML2PS_DIR . 'pdf.fpdf.encryption.php'); - } - - $pipeline = new Pipeline(); - - if (extension_loaded('curl')) { - require_once (HTML2PS_DIR . 'fetcher.url.curl.class.php'); - - $pipeline->fetchers = array(new FetcherURLCurl()); - - if (isset($proxy)) { - if ($proxy != '') { - $pipeline->fetchers[0]->set_proxy($proxy); - } - } - } else { - require_once (HTML2PS_DIR . 'fetcher.url.class.php'); - $pipeline->fetchers[] = new FetcherURL(); - } - - $pipeline->data_filters[] = new DataFilterDoctype(); - $pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']); - - if ($GLOBALS['g_config']['html2xhtml']) { - $pipeline->data_filters[] = new DataFilterHTML2XHTML(); - } else { - $pipeline->data_filters[] = new DataFilterXHTML2XHTML(); - } - - $pipeline->parser = new ParserXHTML(); - $pipeline->pre_tree_filters = array(); - $header_html = ''; - $footer_html = ''; - $filter = new PreTreeFilterHeaderFooter($header_html, $footer_html); - $pipeline->pre_tree_filters[] = $filter; - - if ($GLOBALS['g_config']['renderfields']) { - $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields(); - } - - if ($GLOBALS['g_config']['method'] === 'ps') { - $pipeline->layout_engine = new LayoutEnginePS(); - } else { - $pipeline->layout_engine = new LayoutEngineDefault(); - } - - $pipeline->post_tree_filters = array(); - - if ($GLOBALS['g_config']['pslevel'] == 3) { - $image_encoder = new PSL3ImageEncoderStream(); - } else { - $image_encoder = new PSL2ImageEncoderStream(); - } - - switch ($GLOBALS['g_config']['method']) { - case 'fastps': - if ($GLOBALS['g_config']['pslevel'] == 3) { - $pipeline->output_driver = new OutputDriverFastPS($image_encoder); - } else { - $pipeline->output_driver = new OutputDriverFastPSLevel2($image_encoder); - } - break; - case 'pdflib': - $pipeline->output_driver = new OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']); - break; - case 'fpdf': - $pipeline->output_driver = new OutputDriverFPDF(); - break; - case 'png': - $pipeline->output_driver = new OutputDriverPNG(); - break; - case 'pcl': - $pipeline->output_driver = new OutputDriverPCL(); - break; - default: - die('Unknown output method'); - } - - if (isset($GLOBALS['g_config']['watermarkhtml'])) { - $watermark_text = $GLOBALS['g_config']['watermarkhtml']; - } else { - $watermark_text = ''; - } - - $pipeline->output_driver->set_watermark($watermark_text); - - if ($watermark_text != '') { - $dispatcher = & $pipeline->getDispatcher(); - } - - if ($GLOBALS['g_config']['debugbox']) { - $pipeline->output_driver->set_debug_boxes(true); - } - - if ($GLOBALS['g_config']['draw_page_border']) { - $pipeline->output_driver->set_show_page_border(true); - } - - if ($GLOBALS['g_config']['ps2pdf']) { - $pipeline->output_filters[] = new OutputFilterPS2PDF($GLOBALS['g_config']['pdfversion']); - } - - if ($GLOBALS['g_config']['compress'] && $GLOBALS['g_config']['method'] == 'fastps') { - $pipeline->output_filters[] = new OutputFilterGZip(); - } - - if (!isset($GLOBALS['g_config']['process_mode'])) { - $GLOBALS['g_config']['process_mode'] = ''; - } - - if ($GLOBALS['g_config']['process_mode'] == 'batch') { - $filename = 'batch'; - } else { - $filename = $sFilename; - } - - switch ($GLOBALS['g_config']['output']) { - case 0: - $pipeline->destination = new DestinationBrowser($filename); - break; - case 1: - $pipeline->destination = new DestinationDownload($filename); - break; - case 2: - $pipeline->destination = new DestinationFile($filename); - break; - } - - copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); - try { - $status = $pipeline->process(((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media); - copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf'); - unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf'); - unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); - } catch (Exception $e) { - if ($e->getMessage() == 'ID_OUTPUT_NOT_GENERATE') { - include_once 'classes/model/AppDocument.php'; - $dataDocument = explode('_', $sFilename); - if (!isset($dataDocument[1])) { - $dataDocument[1] = 1; - } - $oAppDocument = new AppDocument(); - $oAppDocument->remove($dataDocument[0], $dataDocument[1]); - G::SendTemporalMessage(G::LoadTranslation('ID_OUTPUT_NOT_GENERATE'), 'Error'); - } - } - } - - /** - * verify if Output row specified in [sUid] exists. - * - * @param string $sUid the uid of the Prolication - */ - public function OutputExists($sUid) - { - $con = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME); - - try { - $oObj = OutputDocumentPeer::retrieveByPk($sUid); - - if (is_object($oObj) && get_class($oObj) == 'OutputDocument') { - return true; - } else { - return false; - } - } catch (Exception $oError) { - throw ($oError); - } - } -} - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ +//require_once ("classes/model/om/BaseOutputDocument.php"); +//require_once ("classes/model/Content.php"); + +/** + * Skeleton subclass for representing a row from the 'OUTPUT_DOCUMENT' table. + * + * + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + * + * @package workflow.engine.classes.model + */ +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_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_template = ''; + + public 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; + } 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['PRO_UID'] = $oOutputDocument->getProUid(); + $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); + } + } + + /** + * 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(); + //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']; + } + $description .= ", Report Generator: ". $aData['OUT_DOC_REPORT_GENERATOR'].", 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($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("CreateOuputDocument", $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->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(); + //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']; + } + $description .= ", Report Generator: ". $aData['OUT_DOC_REPORT_GENERATOR'].", 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($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("UpdateOuputDocument", $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("DeleteOuputDocument", "Output Document Name: ".$outputName.", Output Document Uid: ".$sOutDocUid.", Description: ".$outputDesc.", Filename generated: ".$outputFile); + + 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::replaceDataGridField($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, ' + + + + + + + + + + + +
'); + + fwrite($oFile, $sContent); + fwrite($oFile, "\n
\n\n"); + fclose($oFile); + /* End - Create .doc */ + + if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') { + $oFile = fopen($sPath . $sFilename . '.html', 'wb'); + fwrite($oFile, $sContent); + fclose($oFile); + /* Start - Create .pdf */ + if (isset($aProperties['report_generator'])) { + switch ($aProperties['report_generator']) { + case 'TCPDF': + $this->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties); + break; + case 'HTML2PDF': + default: + $this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties); + break; + } + } else { + $this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties); + } + } + //end if $sTypeDocToGener + /* End - Create .pdf */ + } else { + return PEAR::raiseError( + null, G_ERROR_USER_UID, null, null, 'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!', 'G_Error', true + ); + } + } + + public function generateHtml2pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array()) + { + + // define("MAX_FREE_FRACTION", 1); + define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/'); + G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true); + + require_once(PATH_THIRDPARTY . 'html2pdf/html2pdf.class.php'); + + // define Save file + $sOutput = 2; + $sOrientation = ($sLandscape == false) ? 'P' : 'L'; + $sLang = (defined('SYS_LANG')) ? SYS_LANG : 'en'; + $sMedia = $aProperties['media']; + // margin define + define("MINIMAL_MARGIN", 15); + $marges = array(MINIMAL_MARGIN, MINIMAL_MARGIN, MINIMAL_MARGIN, MINIMAL_MARGIN); + if (isset($aProperties['margins'])) { + // Default marges (left, top, right, bottom) + $margins = $aProperties['margins']; + $margins['left'] = ($margins['left'] > 0) ? $margins['left'] : MINIMAL_MARGIN; + $margins['top'] = ($margins['top'] > 0) ? $margins['top'] : MINIMAL_MARGIN; + $margins['right'] = ($margins['right'] > 0) ? $margins['right'] : MINIMAL_MARGIN; + $margins['bottom'] = ($margins['bottom'] > 0) ? $margins['bottom'] : MINIMAL_MARGIN; + $marges = array($margins['left'], $margins['top'], $margins['right'], $margins['bottom']); + } + + $html2pdf = new HTML2PDF($sOrientation, $sMedia, $sLang, true, 'UTF-8', $marges); + + $html2pdf->pdf->SetAuthor($aFields['USR_USERNAME']); + $html2pdf->pdf->SetTitle('Processmaker'); + $html2pdf->pdf->SetSubject($sFilename); + $html2pdf->pdf->SetCompression(true); + + //$html2pdf->pdf->SetKeywords('HTML2PDF, TCPDF, processmaker'); + + if (isset($aProperties['pdfSecurity'])) { + $pdfSecurity = $aProperties['pdfSecurity']; + $userPass = G::decrypt($pdfSecurity['openPassword'], $sUID); + $ownerPass = ($pdfSecurity['ownerPassword'] != '') ? G::decrypt($pdfSecurity['ownerPassword'], $sUID) : null; + $permissions = explode("|", $pdfSecurity['permissions']); + $html2pdf->pdf->SetProtection($permissions, $userPass, $ownerPass); + } + + $html2pdf->setTestTdInOnePage(false); + $html2pdf->setTestIsImage(false); + $html2pdf->setTestIsDeprecated(false); + + $html2pdf->writeHTML($html2pdf->getHtmlFromPage($sContent)); + + switch ($sOutput) { + case 0: + // Vrew browser + $html2pdf->Output($sPath . $sFilename . '.pdf', 'I'); + break; + case 1: + // Donwnload + $html2pdf->Output($sPath . $sFilename . '.pdf', 'D'); + break; + case 2: + // Save file + $html2pdf->Output($sPath . $sFilename . '.pdf', 'F'); + break; + } + + copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); + + copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf'); + unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf'); + unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); + } + + public function generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array()) + { + require_once (PATH_THIRDPARTY . "tcpdf" . PATH_SEP . "config" . PATH_SEP . "lang" . PATH_SEP . "eng.php"); + require_once (PATH_THIRDPARTY . "tcpdf" . PATH_SEP . "tcpdf.php"); + + $nrt = array("\n", "\r", "\t"); + $nrthtml = array("(n /)", "(r /)", "(t /)"); + + $strContentAux = str_replace($nrt, $nrthtml, $sContent); + $sContent = null; + + while (preg_match("/^(.*)]*)>(.*)$/i", $strContentAux, $arrayMatch)) { + $str = trim($arrayMatch[2]); + $strAttribute = null; + + if (!empty($str)) { + $strAux = $str; + $str = null; + + while (preg_match("/^(.*)([\"'].*[\"'])(.*)$/", $strAux, $arrayMatch2)) { + $strAux = $arrayMatch2[1]; + $str = str_replace(" ", "__SPACE__", $arrayMatch2[2]) . $arrayMatch2[3] . $str; + } + + $str = $strAux . $str; + + //Get attributes + $strStyle = null; + $array = explode(" ", $str); + + foreach ($array as $value) { + $arrayAux = explode("=", $value); + + if (isset($arrayAux[1])) { + $a = trim($arrayAux[0]); + $v = trim(str_replace(array("__SPACE__", "\"", "'"), array(" ", null, null), $arrayAux[1])); + + switch (strtolower($a)) { + case "color": + $strStyle = $strStyle . "color: $v;"; + break; + case "face": + $strStyle = $strStyle . "font-family: $v;"; + break; + case "size": + $arrayPt = array(0, 8, 10, 12, 14, 18, 24, 36); + $strStyle = $strStyle . "font-size: " . $arrayPt[intval($v)] . "pt;"; + break; + case "style": + $strStyle = $strStyle . "$v;"; + break; + default: + $strAttribute = $strAttribute . " $a=\"$v\""; + break; + } + } + } + + if ($strStyle != null) { + $strAttribute = $strAttribute . " style=\"$strStyle\""; + } + } + + $strContentAux = $arrayMatch[1]; + $sContent = "" . $arrayMatch[3] . $sContent; + } + + $sContent = $strContentAux . $sContent; + + $sContent = str_ireplace("", "", $sContent); + + $sContent = str_replace($nrthtml, $nrt, $sContent); + + $sContent = str_replace("margin-left", "text-indent", $sContent); + + // define Save file + $sOutput = 2; + $sOrientation = ($sLandscape == false) ? PDF_PAGE_ORIENTATION : 'L'; + $sMedia = (isset($aProperties['media'])) ? $aProperties['media'] : PDF_PAGE_FORMAT; + $sLang = (defined('SYS_LANG')) ? SYS_LANG : 'en'; + + // create new PDF document + $pdf = new TCPDF($sOrientation, PDF_UNIT, $sMedia, true, 'UTF-8', false); + + // set document information + $pdf->SetCreator(PDF_CREATOR); + $pdf->SetAuthor($aFields['USR_USERNAME']); + $pdf->SetTitle('Processmaker'); + $pdf->SetSubject($sFilename); + $pdf->SetCompression(true); + + $margins = $aProperties['margins']; + $margins["left"] = ($margins["left"] >= 0) ? $margins["left"] : PDF_MARGIN_LEFT; + $margins["top"] = ($margins["top"] >= 0) ? $margins["top"] : PDF_MARGIN_TOP; + $margins["right"] = ($margins["right"] >= 0) ? $margins["right"] : PDF_MARGIN_RIGHT; + $margins["bottom"] = ($margins["bottom"] >= 0) ? $margins["bottom"] : PDF_MARGIN_BOTTOM; + + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + $pdf->SetLeftMargin($margins['left']); + $pdf->SetTopMargin($margins['top']); + $pdf->SetRightMargin($margins['right']); + $pdf->SetAutoPageBreak(true, $margins['bottom']); + + $oServerConf = &serverConf::getSingleton(); + + // set some language dependent data: + $lg = array(); + $lg['a_meta_charset'] = 'UTF-8'; + $lg['a_meta_dir'] = ($oServerConf->isRtl($sLang)) ? 'rtl' : 'ltr'; + $lg['a_meta_language'] = $sLang; + $lg['w_page'] = 'page'; + + //set some language-dependent strings + $pdf->setLanguageArray($lg); + + if (isset($aProperties['pdfSecurity'])) { + $tcpdfPermissions = array('print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'); + $pdfSecurity = $aProperties['pdfSecurity']; + $userPass = G::decrypt($pdfSecurity['openPassword'], $sUID); + $ownerPass = ($pdfSecurity['ownerPassword'] != '') ? G::decrypt($pdfSecurity['ownerPassword'], $sUID) : null; + $permissions = explode("|", $pdfSecurity['permissions']); + $permissions = array_diff($tcpdfPermissions, $permissions); + $pdf->SetProtection($permissions, $userPass, $ownerPass); + } + // --------------------------------------------------------- + // set default font subsetting mode + $pdf->setFontSubsetting(true); + + // Set font + // dejavusans is a UTF-8 Unicode font, if you only need to + // print standard ASCII chars, you can use core fonts like + // helvetica or times to reduce file size. + //$pdf->SetFont('dejavusans', '', 14, '', true); + // Detect chinese, japanese, thai + if (preg_match('/[\x{30FF}\x{3040}-\x{309F}\x{4E00}-\x{9FFF}\x{0E00}-\x{0E7F}]/u', $sContent, $matches)) { + $fileArialunittf = PATH_THIRDPARTY . "tcpdf" . PATH_SEP . "fonts" . PATH_SEP . "arialuni.ttf"; + + $pdf->SetFont((!file_exists($fileArialunittf))? "kozminproregular" : $pdf->addTTFfont($fileArialunittf, "TrueTypeUnicode", "", 32)); + } + + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + // set text shadow effect + //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); + // Print text using writeHTMLCell() + // $pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true); + if (mb_detect_encoding($sContent) == 'UTF-8') { + $sContent = mb_convert_encoding($sContent, 'HTML-ENTITIES', 'UTF-8'); + } + $doc = new DOMDocument('1.0', 'UTF-8'); + if ($sContent != '') { + $doc->loadHtml($sContent); + } + $pdf->writeHTML($doc->saveXML(), false, false, false, false, ''); + // --------------------------------------------------------- + // Close and output PDF document + // This method has several options, check the source code documentation for more information. + //$pdf->Output('example_00.pdf', 'I'); + //$pdf->Output('/home/hector/processmaker/example_00.pdf', 'D'); + switch ($sOutput) { + case 0: + // Vrew browser + $pdf->Output($sPath . $sFilename . '.pdf', 'I'); + break; + case 1: + // Donwnload + $pdf->Output($sPath . $sFilename . '.pdf', 'D'); + break; + case 2: + // Save file + $pdf->Output($sPath . $sFilename . '.pdf', 'F'); + break; + } + } + + public function generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array()) + { + + define("MAX_FREE_FRACTION", 1); + define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/'); + G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true); + require_once (PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php'); + require_once (PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php'); + + parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config'); + + $GLOBALS['g_config'] = array( + 'cssmedia' => 'screen', + 'media' => 'Letter', + 'scalepoints' => false, + 'renderimages' => true, + 'renderfields' => true, + 'renderforms' => false, + 'pslevel' => 3, + 'renderlinks' => true, + 'pagewidth' => 800, + 'landscape' => $sLandscape, + 'method' => 'fpdf', + 'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15,), + 'encoding' => (version_compare(PHP_VERSION, '5.4.0', '<') ? '' : 'utf-8'), + 'ps2pdf' => false, + 'compress' => true, + 'output' => 2, + 'pdfversion' => '1.3', + 'transparency_workaround' => false, + 'imagequality_workaround' => false, + 'draw_page_border' => isset($_REQUEST['pageborder']), + 'debugbox' => false, + 'html2xhtml' => true, + 'mode' => 'html', + 'smartpagebreak' => true + ); + + $GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties); + $g_media = Media::predefined($GLOBALS['g_config']['media']); + $g_media->set_landscape($GLOBALS['g_config']['landscape']); + $g_media->set_margins($GLOBALS['g_config']['margins']); + $g_media->set_pixels($GLOBALS['g_config']['pagewidth']); + + + if (isset($GLOBALS['g_config']['pdfSecurity'])) { + if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) && + $GLOBALS['g_config']['pdfSecurity']['openPassword'] != "" + ) { + $GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt( + $GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID + ); + } + + if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) && + $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != "" + ) { + $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt( + $GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID + ); + } + + $g_media->set_security($GLOBALS['g_config']['pdfSecurity']); + + require_once (HTML2PS_DIR . 'pdf.fpdf.encryption.php'); + } + + $pipeline = new Pipeline(); + + if (extension_loaded('curl')) { + require_once (HTML2PS_DIR . 'fetcher.url.curl.class.php'); + + $pipeline->fetchers = array(new FetcherURLCurl()); + + if (isset($proxy)) { + if ($proxy != '') { + $pipeline->fetchers[0]->set_proxy($proxy); + } + } + } else { + require_once (HTML2PS_DIR . 'fetcher.url.class.php'); + $pipeline->fetchers[] = new FetcherURL(); + } + + $pipeline->data_filters[] = new DataFilterDoctype(); + $pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']); + + if ($GLOBALS['g_config']['html2xhtml']) { + $pipeline->data_filters[] = new DataFilterHTML2XHTML(); + } else { + $pipeline->data_filters[] = new DataFilterXHTML2XHTML(); + } + + $pipeline->parser = new ParserXHTML(); + $pipeline->pre_tree_filters = array(); + $header_html = ''; + $footer_html = ''; + $filter = new PreTreeFilterHeaderFooter($header_html, $footer_html); + $pipeline->pre_tree_filters[] = $filter; + + if ($GLOBALS['g_config']['renderfields']) { + $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields(); + } + + if ($GLOBALS['g_config']['method'] === 'ps') { + $pipeline->layout_engine = new LayoutEnginePS(); + } else { + $pipeline->layout_engine = new LayoutEngineDefault(); + } + + $pipeline->post_tree_filters = array(); + + if ($GLOBALS['g_config']['pslevel'] == 3) { + $image_encoder = new PSL3ImageEncoderStream(); + } else { + $image_encoder = new PSL2ImageEncoderStream(); + } + + switch ($GLOBALS['g_config']['method']) { + case 'fastps': + if ($GLOBALS['g_config']['pslevel'] == 3) { + $pipeline->output_driver = new OutputDriverFastPS($image_encoder); + } else { + $pipeline->output_driver = new OutputDriverFastPSLevel2($image_encoder); + } + break; + case 'pdflib': + $pipeline->output_driver = new OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']); + break; + case 'fpdf': + $pipeline->output_driver = new OutputDriverFPDF(); + break; + case 'png': + $pipeline->output_driver = new OutputDriverPNG(); + break; + case 'pcl': + $pipeline->output_driver = new OutputDriverPCL(); + break; + default: + die('Unknown output method'); + } + + if (isset($GLOBALS['g_config']['watermarkhtml'])) { + $watermark_text = $GLOBALS['g_config']['watermarkhtml']; + } else { + $watermark_text = ''; + } + + $pipeline->output_driver->set_watermark($watermark_text); + + if ($watermark_text != '') { + $dispatcher = & $pipeline->getDispatcher(); + } + + if ($GLOBALS['g_config']['debugbox']) { + $pipeline->output_driver->set_debug_boxes(true); + } + + if ($GLOBALS['g_config']['draw_page_border']) { + $pipeline->output_driver->set_show_page_border(true); + } + + if ($GLOBALS['g_config']['ps2pdf']) { + $pipeline->output_filters[] = new OutputFilterPS2PDF($GLOBALS['g_config']['pdfversion']); + } + + if ($GLOBALS['g_config']['compress'] && $GLOBALS['g_config']['method'] == 'fastps') { + $pipeline->output_filters[] = new OutputFilterGZip(); + } + + if (!isset($GLOBALS['g_config']['process_mode'])) { + $GLOBALS['g_config']['process_mode'] = ''; + } + + if ($GLOBALS['g_config']['process_mode'] == 'batch') { + $filename = 'batch'; + } else { + $filename = $sFilename; + } + + switch ($GLOBALS['g_config']['output']) { + case 0: + $pipeline->destination = new DestinationBrowser($filename); + break; + case 1: + $pipeline->destination = new DestinationDownload($filename); + break; + case 2: + $pipeline->destination = new DestinationFile($filename); + break; + } + + copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); + try { + $status = $pipeline->process(((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media); + copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf'); + unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf'); + unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); + } catch (Exception $e) { + if ($e->getMessage() == 'ID_OUTPUT_NOT_GENERATE') { + include_once 'classes/model/AppDocument.php'; + $dataDocument = explode('_', $sFilename); + if (!isset($dataDocument[1])) { + $dataDocument[1] = 1; + } + $oAppDocument = new AppDocument(); + $oAppDocument->remove($dataDocument[0], $dataDocument[1]); + G::SendTemporalMessage(G::LoadTranslation('ID_OUTPUT_NOT_GENERATE'), 'Error'); + } + } + } + + /** + * verify if Output row specified in [sUid] exists. + * + * @param string $sUid the uid of the Prolication + */ + public function OutputExists($sUid) + { + $con = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME); + + try { + $oObj = OutputDocumentPeer::retrieveByPk($sUid); + + if (is_object($oObj) && get_class($oObj) == 'OutputDocument') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw ($oError); + } + } +} + diff --git a/workflow/engine/classes/model/Triggers.php b/workflow/engine/classes/model/Triggers.php index d0d6a09e0..13321d6d0 100755 --- a/workflow/engine/classes/model/Triggers.php +++ b/workflow/engine/classes/model/Triggers.php @@ -155,7 +155,7 @@ class Triggers extends BaseTriggers } else { $this->setTriUid($aData['TRI_UID'] ); } - + $triggerUid = $this->getTriUid(); $this->setProUid($aData['PRO_UID']); $this->setTriType("SCRIPT"); @@ -183,6 +183,13 @@ class Triggers extends BaseTriggers } $result=$this->save(); $con->commit(); + //Add Audit Log + $description = "Trigger Name: ".$aData['TRI_TITLE'].", Trigger Uid: ".$triggerUid; + if (isset ( $aData['TRI_DESCRIPTION'] )) { + $description .= ", Description: ".$aData['TRI_DESCRIPTION']; + } + G::auditLog("CreateTrigger", $description); + return $result; } else { $con->rollback(); @@ -233,10 +240,18 @@ class Triggers extends BaseTriggers $con->begin(); $oTri = TriggersPeer::retrieveByPK( $TriUid ); if (!is_null($oTri)) { + $triggerName = $this->getTriTitle(); + $triggerDesc = $this->getTriDescription(); Content::removeContent( 'TRI_TITLE', '', $this->getTriUid()); Content::removeContent( 'TRI_DESCRIPTION', '', $this->getTriUid()); $result = $oTri->delete(); $con->commit(); + //Add Audit Log + $description = "Trigger Name: ".$triggerName.", Trigger Uid: ".$TriUid; + if (isset ( $triggerDesc )) { + $description .= ", Description: ".$triggerDesc; + } + G::auditLog("DeleteTrigger", $description); } return $result; } catch (Exception $e) { diff --git a/workflow/engine/js/cases/core/cases_Step_Pmdynaform.js b/workflow/engine/js/cases/core/cases_Step_Pmdynaform.js index ababad45f..0f6af810f 100644 --- a/workflow/engine/js/cases/core/cases_Step_Pmdynaform.js +++ b/workflow/engine/js/cases/core/cases_Step_Pmdynaform.js @@ -49,7 +49,7 @@ $(window).load(function () { submitRest: false }); new PMDynaform.core.Proxy({ - url: "http://" + window.project.keys.server + "/" + window.project.keys.apiName + "/" + window.project.keys.apiVersion + "/" + window.project.keys.workspace + "/cases/" + app_uid + "/variables", + url: "http://" + window.project.keys.server + ":"+port +"/" + window.project.keys.apiName + "/" + window.project.keys.apiVersion + "/" + window.project.keys.workspace + "/cases/" + app_uid + "/variables", method: 'GET', data: {}, keys: window.project.token, diff --git a/workflow/engine/js/cases/core/webentry_pmdynaform.js b/workflow/engine/js/cases/core/webentry_pmdynaform.js new file mode 100644 index 000000000..3fb7228f5 --- /dev/null +++ b/workflow/engine/js/cases/core/webentry_pmdynaform.js @@ -0,0 +1,86 @@ +function dynaFormChanged(frm) { + for (var i1 = 0; i1 <= frm.elements.length - 1; i1++) { + if ((frm.elements[i1].type === "radio" || frm.elements[i1].type === "checkbox") && (frm.elements[i1].checked !== frm.elements[i1].defaultChecked)) { + return true; + } + if ((frm.elements[i1].type === "textarea" || frm.elements[i1].type === "text" || frm.elements[i1].type === "file") && (frm.elements[i1].value !== frm.elements[i1].defaultValue)) { + return true; + } + if (frm.elements[i1].tagName.toLowerCase() === "select") { + var selectDefaultValue = frm.elements[i1].value; + for (var i2 = 0; i2 <= frm.elements[i1].options.length - 1; i2++) { + if (frm.elements[i1].options[i2].defaultSelected) { + selectDefaultValue = frm.elements[i1].options[i2].value; + break; + } + } + if (frm.elements[i1].value !== selectDefaultValue) { + return true; + } + } + } + return false; +} +$(window).load(function () { + if ((navigator.userAgent.indexOf("MSIE") !== -1) || (navigator.userAgent.indexOf("Trident") !== -1)) { + document.body.innerHTML = "
Responsive Dynaforms are not supported in this browser.
"; + return; + } + var data = jsondata; + window.project = new PMDynaform.core.Project({ + data: data, + keys: { + server: location.host, + projectId: prj_uid, + workspace: workspace + }, + token: credentials, + submitRest: false + }); + + var type = document.createElement("input"); + type.type = "hidden"; + type.name = "TYPE"; + type.value = "ASSIGN_TASK"; + var uid = document.createElement("input"); + uid.type = "hidden"; + uid.name = "UID"; + uid.value = dyn_uid; + var position = document.createElement("input"); + position.type = "hidden"; + position.name = "POSITION"; + position.value = "10000"; + var action = document.createElement("input"); + action.type = "hidden"; + action.name = "ACTION"; + action.value = "ASSIGN"; + var dynaformname = document.createElement("input"); + dynaformname.type = "hidden"; + dynaformname.name = "__DynaformName__"; + //dynaformname.value = __DynaformName__; + var appuid = document.createElement("input"); + appuid.type = "hidden"; + appuid.name = "APP_UID"; + + var arrayRequired = document.createElement("input"); + arrayRequired.type = "hidden"; + arrayRequired.name = "DynaformRequiredFields"; + arrayRequired.value = fieldsRequired; + //appuid.value = app_uid; + var form = document.getElementsByTagName("form")[0]; + form.action = filePost; + form.method = "post"; + form.appendChild(type); + form.appendChild(uid); + form.appendChild(position); + form.appendChild(action); + form.appendChild(dynaformname); + form.appendChild(appuid); + form.appendChild(arrayRequired); + + var dyn_forward = document.getElementById("dyn_forward"); + dyn_forward.onclick = function () { + form.submit(); + return false; + }; +}); \ No newline at end of file diff --git a/workflow/engine/methods/events/eventsDelete.php b/workflow/engine/methods/events/eventsDelete.php index 2c5933c3d..373883cbf 100755 --- a/workflow/engine/methods/events/eventsDelete.php +++ b/workflow/engine/methods/events/eventsDelete.php @@ -28,8 +28,15 @@ if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1) { die(); } +$eventInstance = new Event(); +$eventFields = $eventInstance->load($_POST['EVN_UID']); +$proUid = $eventFields['PRO_UID']; + +$infoProcess = new Process(); +$resultProcess = $infoProcess->load($proUid); +G::auditLog('Events','Delete event ('.$_POST['EVN_UID'].') in process "'.$resultProcess['PRO_TITLE'].'"'); + $evnUid = $_POST['EVN_UID']; require_once 'classes/model/Event.php'; $oEvent = new Event(); -$oEvent->remove( $evnUid ); - +$oEvent->remove( $evnUid ); \ No newline at end of file diff --git a/workflow/engine/methods/events/eventsSave.php b/workflow/engine/methods/events/eventsSave.php index bd38f717a..eff6a99db 100755 --- a/workflow/engine/methods/events/eventsSave.php +++ b/workflow/engine/methods/events/eventsSave.php @@ -60,6 +60,10 @@ if ($_POST['form']['EVN_UID'] == '') { $oEvent->update( $_POST['form'] ); } +$infoProcess = new Process(); +$resultProcess = $infoProcess->load($_POST['form']['PRO_UID']); +G::auditLog('Events','Save intermediate message ('.$_POST['form']['EVN_UID'].') in process "'.$resultProcess['PRO_TITLE'].'"'); + function replaceQuotes ($aData) { for ($i = 0; $i < sizeof( $aData ); $i ++) { diff --git a/workflow/engine/methods/events/triggersSave.php b/workflow/engine/methods/events/triggersSave.php index b9402984a..d16381f75 100755 --- a/workflow/engine/methods/events/triggersSave.php +++ b/workflow/engine/methods/events/triggersSave.php @@ -36,3 +36,11 @@ if ($_POST['form']['TRI_UID'] != '') { $oTrigger->update( $_POST['form'] ); +$triggerFields = $oTrigger->load($_POST['form']['TRI_UID']); +$proUid = $triggerFields['PRO_UID']; + +$infoProcess = new Process(); +$resultProcess = $infoProcess->load($proUid); + +G::auditLog('Events','Save event ('.$_POST['form']['TRI_UID'].') in process "'.$resultProcess['PRO_TITLE'].'"'); + diff --git a/workflow/engine/methods/processes/processes_Ajax.php b/workflow/engine/methods/processes/processes_Ajax.php index 7f70d7ddd..d5b56d99c 100755 --- a/workflow/engine/methods/processes/processes_Ajax.php +++ b/workflow/engine/methods/processes/processes_Ajax.php @@ -42,17 +42,93 @@ try { if (isset($_REQUEST['data'])) { if($_REQUEST['action']=="addText"||$_REQUEST['action']=="updateText") { $oData = Bootstrap::json_decode($_REQUEST['data']); + $oDataAux = G::json_decode($_REQUEST['data']); + $oDataAux = (array)$oDataAux; } else { $oData = Bootstrap::json_decode(stripslashes($_REQUEST['data'])); + $oDataAux = G::json_decode(stripslashes($_REQUEST['data'])); + $oDataAux = (array)$oDataAux; } //$oData = $oJSON->decode( stripslashes( $_REQUEST['data'] ) ); $sOutput = ''; $sTask = ''; + + if(array_key_exists('pro_uid', $oDataAux) || array_key_exists('uid', $oDataAux) || array_key_exists('PRO_UID', $oDataAux) || array_key_exists('UID', $oDataAux)) { + if(array_key_exists('pro_uid', $oDataAux) || array_key_exists('PRO_UID', $oDataAux)) { + if(array_key_exists('pro_uid', $oDataAux)) { + $proUid = $oDataAux['pro_uid']; + } else { + $proUid = $oDataAux['PRO_UID']; + } + } else { + $proUid = $oDataAux['uid']; + $uidAux = $proUid; + } + + G::LoadClass('processes'); + $infoProcess = new Processes(); + + if(!$infoProcess->processExists($proUid)) { + $oSL = new SwimlanesElements(); + if($oSL->swimlanesElementsExists($proUid)) { + $aFields = $oSL->load($proUid); + $proUid = $aFields['PRO_UID']; + } else { + $k = new Criteria('workflow'); + $k->clearSelectColumns(); + $k->addSelectColumn(TaskPeer::PRO_UID); + $k->add(TaskPeer::TAS_UID, $uidAux ); + $rs = TaskPeer::doSelectRS($k); + $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $rs->next(); + $row = $rs->getRow(); + $proUid = $row['PRO_UID']; + } + } + $resultProcess = $infoProcess->getProcessRow($proUid); + } else { + if(array_key_exists('PU_UID', $oDataAux)) { + $c = new Criteria('workflow'); + $c->clearSelectColumns(); + $c->addSelectColumn(ProcessUserPeer::PRO_UID); + $c->addSelectColumn(ProcessUserPeer::USR_UID); + $c->add(ProcessUserPeer::PU_UID, $oData->PU_UID); + $oDataset = AppDelegationPeer::doSelectRS($c); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + $row = $oDataset->getRow(); + $userSupervisor = $row['USR_UID']; + + G::LoadClass('processes'); + $infoProcess = new Processes(); + $resultProcess = $infoProcess->getProcessRow($row['PRO_UID']); + } + } } - + + if(isset($_REQUEST['pro_uid']) && !empty($_REQUEST['pro_uid']) || isset($_REQUEST['PRO_UID']) && !empty($_REQUEST['PRO_UID'])) { + if(isset($_REQUEST['pro_uid']) && !empty($_REQUEST['pro_uid'])) { + $proUid = $_REQUEST['pro_uid']; + } else { + $proUid = $_REQUEST['PRO_UID']; + } + G::LoadClass('processes'); + $infoProcess = new Processes(); + $resultProcess = $infoProcess->getProcessRow($proUid); + } + + if($proUid != "") { + $valuesProcess['PRO_UID'] = $proUid; + $valuesProcess['PRO_UPDATE_DATE'] = date("Y-m-d H:m:i"); + G::LoadClass('processes'); + $infoProcess = new Processes(); + $resultProcess = $infoProcess->updateProcessRow($valuesProcess); + $resultProcess = $infoProcess->getProcessRow($proUid); + } + //G::LoadClass( 'processMap' ); $oProcessMap = new processMap(new DBConnection()); - + switch ($_REQUEST['action']) { case 'load': $_SESSION['PROCESS'] = $oData->uid; @@ -85,6 +161,7 @@ try { break; case 'process_Export': include (PATH_METHODS . 'processes/processes_Export.php'); + G::auditLog('ExportProcess','Export Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'process_User': include (PATH_METHODS . 'processes/processes_User.php'); @@ -101,9 +178,14 @@ try { break; case 'webEntry_delete': $form = $_REQUEST; - unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . $form['FILENAME']); - unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . str_replace(".php", "Post", $form['FILENAME']) . ".php"); + if(file_exists(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . $form['FILENAME'])) { + unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . $form['FILENAME']); + } + if(file_exists(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . str_replace(".php", "Post", $form['FILENAME']) . ".php")) { + unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . str_replace(".php", "Post", $form['FILENAME']) . ".php"); + } $oProcessMap->webEntry($_REQUEST['PRO_UID']); + G::auditLog('WebEntry','Delete web entry ('.$form['FILENAME'].') in process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'webEntry_new': $oProcessMap->webEntry_new($oData->PRO_UID); @@ -113,6 +195,7 @@ try { G::LoadClass('processMap'); $oProcessMap = new ProcessMap(); $oProcessMap->listProcessesUser($oData->PRO_UID); + G::auditLog('AssignRole','Assign new supervisor ('.$oData->USR_UID.') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'removeProcessUser': $oProcessMap->removeProcessUser($oData->PU_UID); @@ -122,6 +205,8 @@ try { break; } } + + G::auditLog('RemoveUser','Remove supervisor ('.$userSupervisor.') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'supervisorDynaforms': $oProcessMap->supervisorDynaforms($oData->pro_uid); @@ -159,9 +244,11 @@ try { break; case 'addTask': $sOutput = $oProcessMap->addTask($oData->uid, $oData->position->x, $oData->position->y); + G::auditLog('AddTask','Add new task in process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'addSubProcess': $sOutput = $oProcessMap->addSubProcess($oData->uid, $oData->position->x, $oData->position->y); + G::auditLog('AddSubProcess','Add new sub process in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'taskColor': $oTask->taskColor($oData->pro_uid, $oData->tas_uid); @@ -174,33 +261,48 @@ try { break; case 'saveTaskPosition': $sOutput = $oProcessMap->saveTaskPosition($oData->uid, $oData->position->x, $oData->position->y); + $oTask = new Task(); + $oTask->load($uidAux); + G::auditLog('SaveTaskPosition','Change task position ('.$oTask->getTasTitle().') in process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'deleteTask': $sOutput = $oProcessMap->deleteTask($oData->tas_uid); break; case 'addGuide': $sOutput = $oProcessMap->addGuide($oData->uid, $oData->position, $oData->direction); + $sOutputAux = G::json_decode($sOutput); + $sOutputAux = (array)$sOutputAux; + G::auditLog('Add'.ucwords($oDataAux['direction']).'Line','Add '.$oDataAux['direction'].' line ('.$sOutputAux['uid'].') in process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'saveGuidePosition': $sOutput = $oProcessMap->saveGuidePosition($oData->uid, $oData->position, $oData->direction); + G::auditLog('SaveGuidePosition','Change '.$oData->direction.' line position in process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'deleteGuide': $sOutput = $oProcessMap->deleteGuide($oData->uid); + G::auditLog('DeleteLine','Delete line ('.$oData->uid.') in process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'deleteGuides': $sOutput = $oProcessMap->deleteGuides($oData->pro_uid); + G::auditLog('DeleteLines','Delete all lines in process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'addText': $sOutput = $oProcessMap->addText($oData->uid, $oData->label, $oData->position->x, $oData->position->y); + $sOutputAux = G::json_decode($sOutput); + $sOutputAux = (array)$sOutputAux; + G::auditLog('AddText','Add new text ('.$sOutputAux['uid'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'updateText': $sOutput = $oProcessMap->updateText($oData->uid, $oData->label); + G::auditLog('UpdateText','Edit text ('.$oData->uid.' ) in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'saveTextPosition': $sOutput = $oProcessMap->saveTextPosition($oData->uid, $oData->position->x, $oData->position->y); + G::auditLog('SaveTextPosition','Change text position ('.$oData->uid.' ) in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'deleteText': $sOutput = $oProcessMap->deleteText($oData->uid); + G::auditLog('DeleteText','Delete text ('.$oData->uid.' ) in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'dynaforms': $oProcessMap->dynaformsList($oData->pro_uid); @@ -326,9 +428,11 @@ try { case 'exploreDirectory': $_SESSION["PFMDirectory"] = $oData->main_directory; $oProcessMap->exploreDirectory($oData->pro_uid, $oData->main_directory, $oData->directory); + G::auditLog('ProcessFileManager','Upload template ('.$oData->main_directory.') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'deleteFile': $oProcessMap->deleteFile($oData->pro_uid, $oData->main_directory, $oData->directory, $oData->file); + G::auditLog('ProcessFileManager','Delete template ('.$oData->main_directory.': '.$oData->file.') in process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'deleteDirectory': $oProcessMap->deleteDirectory($oData->pro_uid, $oData->main_directory, $oData->directory, $oData->dir_to_delete); @@ -440,9 +544,11 @@ try { switch ($sDir) { case 'mailTemplates': $sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename']; + G::auditLog('ProcessFileManager','Edit template ('.$_REQUEST['filename'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'public': $sDirectory = PATH_DATA_PUBLIC . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename']; + G::auditLog('ProcessFileManager','Edit public template ('.$_REQUEST['filename'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; default: $sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename']; @@ -530,9 +636,11 @@ try { switch ($sDir) { case 'mailTemplates': $sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename']; + G::auditLog('ProcessFileManager','Save template ('.$_REQUEST['filename'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'public': $sDirectory = PATH_DATA_PUBLIC . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename']; + G::auditLog('ProcessFileManager','Save public template ('.$_REQUEST['filename'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; default: $sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename']; diff --git a/workflow/engine/methods/processes/processes_DeleteObjectPermission.php b/workflow/engine/methods/processes/processes_DeleteObjectPermission.php index fd9f97a8e..40e52145c 100755 --- a/workflow/engine/methods/processes/processes_DeleteObjectPermission.php +++ b/workflow/engine/methods/processes/processes_DeleteObjectPermission.php @@ -58,3 +58,7 @@ try { $result->msg = $e->getMessage(); } print G::json_encode( $result ); + +$infoProcess = new Processes(); +$resultProcess = $infoProcess->getProcessRow($sProcessUID); +G::auditLog('DeletePermissions','Delete Permissions ('.$_GET['OP_UID'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); diff --git a/workflow/engine/methods/processes/processes_Save.php b/workflow/engine/methods/processes/processes_Save.php index 60c6824f5..6678ce79e 100755 --- a/workflow/engine/methods/processes/processes_Save.php +++ b/workflow/engine/methods/processes/processes_Save.php @@ -30,7 +30,8 @@ //G::LoadThirdParty( 'pear/json', 'class.json' ); $function = isset( $_POST['function'] ) ? $_POST['function'] : ''; - +$infoProcess = new Process(); +$resultProcessOld = $infoProcess->load($_POST['form']['PRO_UID']); switch ($function) { case 'lookForNameProcess': require_once 'classes/model/Content.php'; @@ -91,4 +92,54 @@ switch ($function) { } break; -} \ No newline at end of file +} +$resultProcessNew = $infoProcess->load($_POST['form']['PRO_UID']); +$oldFields = array_diff_assoc($resultProcessOld,$resultProcessNew); +$newFields = array_diff_assoc($resultProcessNew,$resultProcessOld); + +if(array_key_exists('PRO_TITLE', $newFields)) { + $fields[] = G::LoadTranslation('ID_TITLE'); +} +if(array_key_exists('PRO_DESCRIPTION', $newFields)) { + $fields[] = G::LoadTranslation('ID_DESCRIPTION'); +} +if(array_key_exists('PRO_CALENDAR', $newFields)) { + $fields[] = G::LoadTranslation('ID_CALENDAR'); +} +if(array_key_exists('PRO_CATEGORY', $newFields)) { + $fields[] = "Process Category"; +} +if(array_key_exists('PRO_SUMMARY_DYNAFORM', $newFields)) { + $fields[] = "Dynaform to show a case summary"; +} +if(array_key_exists('PRO_DERIVATION_SCREEN_TPL', $newFields)) { + $fields[] = "Routing Screen Template"; +} +if(array_key_exists('PRO_DEBUG', $newFields)) { + $fields[] = G::LoadTranslation('ID_PRO_DEBUG'); +} +if(array_key_exists('PRO_SHOW_MESSAGE', $newFields)) { + $fields[] = "Hide the case number and the case title in the steps"; +} +if(array_key_exists('PRO_SUBPROCESS', $newFields)) { + $fields[] = "This a sub process"; +} +if(array_key_exists('PRO_TRI_DELETED', $newFields)) { + $fields[] = "Execute a trigger when a case is deleted"; +} +if(array_key_exists('PRO_TRI_CANCELED', $newFields)) { + $fields[] = "Execute a trigger when a case is canceled"; +} +if(array_key_exists('PRO_TRI_PAUSED', $newFields)) { + $fields[] = "Execute a trigger when a case is paused"; +} +if(array_key_exists('PRO_TRI_REASSIGNED', $newFields)) { + $fields[] = "Execute a trigger when a case is reassigned"; G +} +if(array_key_exists('PRO_TRI_UNPAUSED', $newFields)) { + $fields[] = "Execute a trigger when a case is unpaused"; +} +if(array_key_exists('PRO_TYPE_PROCESS', $newFields)) { + $fields[] = "Type of process (only owners can edit private processes)"; +} +G::auditLog('EditProcess','Edit fields ('.implode(', ',$fields).') in process "'.$_POST['form']['PRO_TITLE'].'"'); \ No newline at end of file diff --git a/workflow/engine/methods/processes/processes_SaveObjectPermission.php b/workflow/engine/methods/processes/processes_SaveObjectPermission.php index 4557e01d5..11d6c50d9 100755 --- a/workflow/engine/methods/processes/processes_SaveObjectPermission.php +++ b/workflow/engine/methods/processes/processes_SaveObjectPermission.php @@ -76,3 +76,8 @@ $oOP->save(); G::LoadClass( 'processMap' ); $oProcessMap = new ProcessMap(); $oProcessMap->getObjectsPermissionsCriteria( $sValue['PRO_UID'] ); + +$infoProcess = new Processes(); +$resultProcess = $infoProcess->getProcessRow($sValue['PRO_UID']); +$participation = $sValue['OP_PARTICIPATE'] == 1 ? "YES" : "NO"; +G::auditLog('ProcessPermissions','Add Permission (group or user: '.end(explode( '|', $sValue['GROUP_USER'] )).', permission: '.$sValue['OP_ACTION'].', status case: '.$sValue['OP_CASE_STATUS'].', type: '.$sValue['OP_OBJ_TYPE'].', participation required: '.$participation.') in Process "'.$resultProcess['PRO_TITLE'].'"'); diff --git a/workflow/engine/methods/processes/processes_webEntryGenerate.php b/workflow/engine/methods/processes/processes_webEntryGenerate.php index 8909bc3a8..78680d1ac 100755 --- a/workflow/engine/methods/processes/processes_webEntryGenerate.php +++ b/workflow/engine/methods/processes/processes_webEntryGenerate.php @@ -38,6 +38,9 @@ try { $http = 'http://'; $sContent = ''; + + $infoProcess = new Process(); + $resultProcess = $infoProcess->load($sPRO_UID); if ($withWS) { //creating sys.info; @@ -73,6 +76,8 @@ try { $template->assign( 'wsUser', $sWS_USER ); $template->assign( 'wsPass', Bootstrap::hashPassword($sWS_PASS, '', true) ); $template->assign( 'wsRoundRobin', $sWS_ROUNDROBIN ); + + G::auditLog('WebEntry','Generate web entry with web services ('.$dynTitle.'.php) in process "'.$resultProcess['PRO_TITLE'].'"'); if ($sWE_USR == "2") { $template->assign( 'USR_VAR', "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;" ); @@ -118,8 +123,7 @@ try { $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; print $link; //print "\n $link "; - - + } else { $G_FORM = new Form( $sPRO_UID . '/' . $sDYNAFORM, PATH_DYNAFORM, SYS_LANG, false ); $G_FORM->action = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/cases_StartExternal.php'; @@ -159,6 +163,7 @@ try { } print_r( '' ); + G::auditLog('WebEntry','Generate web entry with single HTML (dynaform uid: '.$sDYNAFORM.') in process "'.$resultProcess['PRO_TITLE'].'"'); } } catch (Exception $e) { diff --git a/workflow/engine/methods/steps/steps_SupervisorAjax.php b/workflow/engine/methods/steps/steps_SupervisorAjax.php index e9039ee50..b5d2a912f 100755 --- a/workflow/engine/methods/steps/steps_SupervisorAjax.php +++ b/workflow/engine/methods/steps/steps_SupervisorAjax.php @@ -41,6 +41,9 @@ try { G::LoadClass( 'processMap' ); $oProcessMap = new ProcessMap(); + + $infoProcess = new Processes(); + $resultProcess = $infoProcess->getProcessRow($_POST['PRO_UID']); switch ($_POST['action']) { case 'availableSupervisorDynaforms': @@ -48,18 +51,22 @@ try { break; case 'assignSupervisorDynaform': $oProcessMap->assignSupervisorStep( $_POST['PRO_UID'], 'DYNAFORM', $_POST['DYN_UID'] ); + G::auditLog('AssignSupervisorDynaform','Assign Supervisor Dynaform ('.$_POST['DYN_UID'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'removeSupervisorDynaform': $oProcessMap->removeSupervisorStep( $_POST['STEP_UID'], $_POST['PRO_UID'], 'DYNAFORM', $_POST['DYN_UID'], $_POST['STEP_POSITION'] ); + G::auditLog('RemoveSupervisorDynaform','Remove Supervisor Dynaform ('.$_POST['DYN_UID'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'availableSupervisorInputs': $oProcessMap->availableSupervisorInputs( $_POST['PRO_UID'] ); break; case 'assignSupervisorInput': $oProcessMap->assignSupervisorStep( $_POST['PRO_UID'], 'INPUT_DOCUMENT', $_POST['INP_DOC_UID'] ); + G::auditLog('AssignSupervisorInput','Assign Supervisor Input ('.$_POST['INP_DOC_UID'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'removeSupervisorInput': $oProcessMap->removeSupervisorStep( $_POST['STEP_UID'], $_POST['PRO_UID'], 'INPUT_DOCUMENT', $_POST['INP_DOC_UID'], $_POST['STEP_POSITION'] ); + G::auditLog('RemoveSupervisorInput','Remove Supervisor Input ('.$_POST['INP_DOC_UID'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; } } catch (Exception $oException) { diff --git a/workflow/engine/methods/tracker/tracker_Ajax.php b/workflow/engine/methods/tracker/tracker_Ajax.php index 8551aeedc..1c574c3ba 100755 --- a/workflow/engine/methods/tracker/tracker_Ajax.php +++ b/workflow/engine/methods/tracker/tracker_Ajax.php @@ -25,6 +25,10 @@ try { if (isset( $_POST['form']['action'] )) { $_POST['action'] = $_POST['form']['action']; } + + $infoProcess = new Process(); + $resultProcess = $infoProcess->load($_POST['PRO_UID']); + switch ($_POST['action']) { case 'availableCaseTrackerObjects': G::LoadClass( 'processMap' ); @@ -37,24 +41,28 @@ try { $cto_UID = $oProcessMap->assignCaseTrackerObject( $_POST['PRO_UID'], $_POST['OBJECT_TYPE'], $_POST['OBJECT_UID'] ); $oProcessMap->getCaseTrackerObjectsCriteria( $_POST['PRO_UID'] ); echo $cto_UID; + G::auditLog('CaseTrackers','Assign Case Tracker Object ('.$cto_UID.' - '.$_POST['OBJECT_TYPE'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'removeCaseTrackerObject': G::LoadClass( 'processMap' ); $oProcessMap = new ProcessMap(); $oProcessMap->removeCaseTrackerObject( $_POST['CTO_UID'], $_POST['PRO_UID'], $_POST['STEP_POSITION'] ); $oProcessMap->getCaseTrackerObjectsCriteria( $_POST['PRO_UID'] ); + G::auditLog('CaseTrackers','Remove Case Tracker Object ('.$_POST['CTO_UID'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'upCaseTrackerObject': G::LoadClass( 'processMap' ); $oProcessMap = new ProcessMap(); $oProcessMap->upCaseTrackerObject( $_POST['CTO_UID'], $_POST['PRO_UID'], $_POST['STEP_POSITION'] ); $oProcessMap->getCaseTrackerObjectsCriteria( $_POST['PRO_UID'] ); + G::auditLog('CaseTrackers','Move Up Case Tracker Object ('.$_POST['CTO_UID'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'downCaseTrackerObject': G::LoadClass( 'processMap' ); $oProcessMap = new ProcessMap(); $oProcessMap->downCaseTrackerObject( $_POST['CTO_UID'], $_POST['PRO_UID'], $_POST['STEP_POSITION'] ); $oProcessMap->getCaseTrackerObjectsCriteria( $_POST['PRO_UID'] ); + G::auditLog('CaseTrackers','Move Down Case Tracker Object ('.$_POST['CTO_UID'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); break; case 'editStagesMap': $oTemplatePower = new TemplatePower( PATH_TPL . 'tracker/stages_Map.html' ); diff --git a/workflow/engine/methods/tracker/tracker_ConditionsSave.php b/workflow/engine/methods/tracker/tracker_ConditionsSave.php index 4ef89a7bd..b41818d64 100755 --- a/workflow/engine/methods/tracker/tracker_ConditionsSave.php +++ b/workflow/engine/methods/tracker/tracker_ConditionsSave.php @@ -48,6 +48,10 @@ try { $aFields = $oCaseTrackerObject->load( $value['CTO_UID'] ); $aFields['CTO_CONDITION'] = $value['CTO_CONDITION']; $oCaseTrackerObject->update( $aFields ); + + $infoProcess = new Process(); + $resultProcess = $infoProcess->load($value['PRO_UID']); + G::auditLog('CaseTrackers','Save Condition Case Tracker Object ('.$value['CTO_UID'].', condition: '.$value['CTO_CONDITION'].') in Process "'.$resultProcess['PRO_TITLE'].'"'); } catch (Exception $oException) { die( $oException->getMessage() ); } diff --git a/workflow/engine/methods/tracker/tracker_Save.php b/workflow/engine/methods/tracker/tracker_Save.php index fcc27d712..4e6e40dd6 100755 --- a/workflow/engine/methods/tracker/tracker_Save.php +++ b/workflow/engine/methods/tracker/tracker_Save.php @@ -15,3 +15,14 @@ require_once 'classes/model/CaseTracker.php'; $oCaseTracker = new CaseTracker(); $oCaseTracker->update( $sValue ); +$infoProcess = new Process(); +$resultProcess = $infoProcess->load($sValue['PRO_UID']); + +if($sValue['CT_DERIVATION_HISTORY'] == 1) { + $type[] = "Routing History"; +} +if($sValue['CT_MESSAGE_HISTORY'] == 1) { + $type[] = "Messages History"; +} +G::auditLog('CaseTrackers','Save Case Tracker Properties ('.$sValue['CT_MAP_TYPE'].' - '.implode(', ',$type).') in Process "'.$resultProcess['PRO_TITLE'].'"'); + diff --git a/workflow/engine/methods/triggers/triggers_Save.php b/workflow/engine/methods/triggers/triggers_Save.php index a36d7ed6c..b7abc6627 100755 --- a/workflow/engine/methods/triggers/triggers_Save.php +++ b/workflow/engine/methods/triggers/triggers_Save.php @@ -101,15 +101,27 @@ if (isset( $sfunction ) && $sfunction == 'lookforNameTrigger') { } /*----------------------------------********---------------------------------*/ } - + $swCreate = true; if ($value['TRI_UID'] != '') { $oTrigger->load( $value['TRI_UID'] ); } else { $oTrigger->create( $value ); $value['TRI_UID'] = $oTrigger->getTriUid(); - } - //print_r($_POST['form']);die; + $swCreate = false; + } $oTrigger->update( $value ); + if($swCreate){ + //Add Audit Log + $fields = $oTrigger->load( $value['TRI_UID'] ); + $description = "Trigger Name: ".$fields['TRI_TITLE'].", Trigger Uid: ".$value['TRI_UID']; + if (isset ( $fields['TRI_DESCRIPTION'] )) { + $description .= ", Description: ".$fields['TRI_DESCRIPTION']; + } + if (isset($value["TRI_WEBBOT"])) { + $description .= ", [EDIT CODE]"; + } + G::auditLog("UpdateTrigger", $description); + } //if (! isset( $_POST['mode'] )) { // $oProcessMap->triggersList( $value['PRO_UID'] ); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/FilesManager.php b/workflow/engine/src/ProcessMaker/BusinessModel/FilesManager.php index 2953a3ba1..c8a8830fe 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/FilesManager.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/FilesManager.php @@ -275,6 +275,10 @@ class FilesManager $_FILES['prf_file']['name'] = $_FILES['prf_file']['name'].$extention; } $file = end(explode("/",$path)); + if(strpos($file,"\\") > 0) { + $file = str_replace('\\', '/', $file); + $file = end(explode("/",$file)); + } $path = str_replace($file,'',$path); if ($file == $_FILES['prf_file']['name']) { if ($_FILES['prf_file']['error'] != 1) { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php index ed8d7bdd3..52511af14 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php @@ -395,9 +395,17 @@ class WebEntry $fileContent .= "\$_SESSION[\"PROCESS\"] = \"" . $processUid . "\";\n"; $fileContent .= "\$_SESSION[\"CURRENT_DYN_UID\"] = \"" . $dynaFormUid . "\";\n"; $fileContent .= "\$G_PUBLISH = new Publisher();\n"; + + + $fileContent .= "G::LoadClass('pmDynaform');\n"; + $fileContent .= "\$a = new pmDynaform('".$arrayWebEntryData["DYN_UID"]."', array());\n"; + $fileContent .= "if(\$a->isResponsive()){"; + $fileContent .= "\$a->printWebEntry('".$fileName."Post.php');"; + $fileContent .= "}else {"; $fileContent .= "\$G_PUBLISH->AddContent(\"dynaform\", \"xmlform\", \"" . $processUid . "/" . $dynaFormUid . "\", \"\", array(), \"" . $fileName . "Post.php\");\n"; $fileContent .= "G::RenderPage(\"publish\", \"blank\");"; - + $fileContent .= "}"; + file_put_contents($pathDataPublicProcess . PATH_SEP . $fileName . ".php", $fileContent); //Creating the second file, the post file who receive the post form. diff --git a/workflow/engine/templates/cases/WebEntry_Pmdynaform.html b/workflow/engine/templates/cases/WebEntry_Pmdynaform.html new file mode 100644 index 000000000..d55f866f5 --- /dev/null +++ b/workflow/engine/templates/cases/WebEntry_Pmdynaform.html @@ -0,0 +1,53 @@ + + + + PMDynaform + + + + + + + + + + + + + +
+ ###TEMPLATES### + + + + + + + + +
+
+   + + +   + + Next Step + +
+ + diff --git a/workflow/engine/templates/cases/cases_Step_Pmdynaform.html b/workflow/engine/templates/cases/cases_Step_Pmdynaform.html index cae588671..8fabe6c67 100644 --- a/workflow/engine/templates/cases/cases_Step_Pmdynaform.html +++ b/workflow/engine/templates/cases/cases_Step_Pmdynaform.html @@ -27,6 +27,7 @@ var prj_uid = '{PRJ_UID}'; var step_mode = '{STEP_MODE}'; var workspace = '{WORKSPACE}'; + var port = '{PORT}'; var credentials = {credentials};