PMC-17
This commit is contained in:
@@ -351,6 +351,17 @@ EOT
|
|||||||
CLI::taskArg('workspace');
|
CLI::taskArg('workspace');
|
||||||
CLI::taskRun("run_clear_dyn_content_history_data");
|
CLI::taskRun("run_clear_dyn_content_history_data");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync JSON definition of the Forms with Input Documents information
|
||||||
|
*/
|
||||||
|
CLI::taskName('sync-forms-with-info-from-input-documents');
|
||||||
|
CLI::taskDescription(<<<EOT
|
||||||
|
Sync JSON definition of the Forms with Input Documents information
|
||||||
|
EOT
|
||||||
|
);
|
||||||
|
CLI::taskArg('workspace');
|
||||||
|
CLI::taskRun("run_sync_forms_with_info_from_input_documents");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function run_info
|
* Function run_info
|
||||||
*
|
*
|
||||||
@@ -1306,3 +1317,34 @@ function run_clear_dyn_content_history_data($args, $opts)
|
|||||||
$stop = microtime(true);
|
$stop = microtime(true);
|
||||||
CLI::logging("<*> Cleaning history data from APP_HISTORY process took " . ($stop - $start) . " seconds.\n");
|
CLI::logging("<*> Cleaning history data from APP_HISTORY process took " . ($stop - $start) . " seconds.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync JSON definition of the Forms with Input Documents information
|
||||||
|
*
|
||||||
|
* @param array $args
|
||||||
|
* @param array $opts
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function run_sync_forms_with_info_from_input_documents($args, $opts) {
|
||||||
|
if (count($args) === 1) {
|
||||||
|
//This variable is not defined and does not involve its value in this
|
||||||
|
//task, it is removed at the end of the method.
|
||||||
|
$_SERVER['REQUEST_URI'] = '';
|
||||||
|
if (!defined('SYS_SKIN')) {
|
||||||
|
$conf = new Configurations();
|
||||||
|
define('SYS_SKIN', $conf->getConfiguration('SKIN_CRON', ''));
|
||||||
|
}
|
||||||
|
CLI::logging('Sync JSON definition of the Forms with Input Documents information from workspace: ' . pakeColor::colorize($args[0], 'INFO') . "\n");
|
||||||
|
$workspaceTools = new WorkspaceTools($args[0]);
|
||||||
|
$workspaceTools->syncFormsWithInputDocumentInfo();
|
||||||
|
unset($_SERVER['REQUEST_URI']);
|
||||||
|
} else {
|
||||||
|
$workspaces = get_workspaces_from_args($args);
|
||||||
|
foreach ($workspaces as $workspace) {
|
||||||
|
passthru(PHP_BINARY . ' processmaker sync-forms-with-info-from-input-documents ' .
|
||||||
|
$workspace->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1507,12 +1507,21 @@ class PmDynaform
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync JSON definition of the Forms with Input Document information
|
||||||
|
* in all forms from a process
|
||||||
|
*
|
||||||
|
* @param string $processUid
|
||||||
|
* @param array $inputDocument
|
||||||
|
*/
|
||||||
public function synchronizeInputDocument($processUid, $inputDocument)
|
public function synchronizeInputDocument($processUid, $inputDocument)
|
||||||
{
|
{
|
||||||
$criteria = new Criteria("workflow");
|
$criteria = new Criteria('workflow');
|
||||||
$criteria->addSelectColumn(DynaformPeer::DYN_UID);
|
$criteria->addSelectColumn(DynaformPeer::DYN_UID);
|
||||||
$criteria->addSelectColumn(DynaformPeer::DYN_CONTENT);
|
$criteria->addSelectColumn(DynaformPeer::DYN_CONTENT);
|
||||||
$criteria->add(DynaformPeer::PRO_UID, $processUid, Criteria::EQUAL);
|
$criteria->add(DynaformPeer::PRO_UID, $processUid, Criteria::EQUAL);
|
||||||
|
// Only select the forms with an input document related to a field
|
||||||
|
$criteria->add(DynaformPeer::DYN_CONTENT, '%"sizeUnity":%', Criteria::LIKE);
|
||||||
$rsCriteria = DynaformPeer::doSelectRS($criteria);
|
$rsCriteria = DynaformPeer::doSelectRS($criteria);
|
||||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
while ($rsCriteria->next()) {
|
while ($rsCriteria->next()) {
|
||||||
@@ -1524,7 +1533,7 @@ class PmDynaform
|
|||||||
if ($json2 !== $aRow['DYN_CONTENT']) {
|
if ($json2 !== $aRow['DYN_CONTENT']) {
|
||||||
$con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
|
$con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
|
||||||
$con->begin();
|
$con->begin();
|
||||||
$oPro = DynaformPeer::retrieveByPk($aRow["DYN_UID"]);
|
$oPro = DynaformPeer::retrieveByPk($aRow['DYN_UID']);
|
||||||
$oPro->setDynContent($json2);
|
$oPro->setDynContent($json2);
|
||||||
$oPro->save();
|
$oPro->save();
|
||||||
$con->commit();
|
$con->commit();
|
||||||
@@ -1532,6 +1541,13 @@ class PmDynaform
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace values from an Input Document related to the form,
|
||||||
|
* for fields of type "file" and "multipleFile"
|
||||||
|
*
|
||||||
|
* @param object $json
|
||||||
|
* @param array $inputDocument
|
||||||
|
*/
|
||||||
private function jsonsid(&$json, $inputDocument)
|
private function jsonsid(&$json, $inputDocument)
|
||||||
{
|
{
|
||||||
foreach ($json as $key => $value) {
|
foreach ($json as $key => $value) {
|
||||||
@@ -1541,15 +1557,8 @@ class PmDynaform
|
|||||||
$this->jsonsid($value, $inputDocument);
|
$this->jsonsid($value, $inputDocument);
|
||||||
}
|
}
|
||||||
if (!$sw1 && !$sw2) {
|
if (!$sw1 && !$sw2) {
|
||||||
if ($key === "type" && $json->type === "file" && $json->variable !== "") {
|
if ($key === "type" && ($json->type === "file" || $json->type === "multipleFile") && isset($json->inp_doc_uid)) {
|
||||||
$a = new Criteria("workflow");
|
if ($json->inp_doc_uid === $inputDocument["INP_DOC_UID"]) {
|
||||||
$a->addSelectColumn(ProcessVariablesPeer::INP_DOC_UID);
|
|
||||||
$a->add(ProcessVariablesPeer::VAR_NAME, $json->variable, Criteria::EQUAL);
|
|
||||||
$ds = DynaformPeer::doSelectRS($a);
|
|
||||||
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$ds->next();
|
|
||||||
$row = $ds->getRow();
|
|
||||||
if (isset($row) && $row["INP_DOC_UID"] === $inputDocument["INP_DOC_UID"]) {
|
|
||||||
if (isset($json->size)) {
|
if (isset($json->size)) {
|
||||||
$json->size = $inputDocument["INP_DOC_MAX_FILESIZE"];
|
$json->size = $inputDocument["INP_DOC_MAX_FILESIZE"];
|
||||||
}
|
}
|
||||||
@@ -1560,6 +1569,8 @@ class PmDynaform
|
|||||||
$json->extensions = $inputDocument["INP_DOC_TYPE_FILE"];
|
$json->extensions = $inputDocument["INP_DOC_TYPE_FILE"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if ($key === "type" && $json->type === "grid" && !empty($json->columns)) {
|
||||||
|
$this->jsonsid($json->columns, $inputDocument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use Illuminate\Support\Facades\DB;
|
|||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
use ProcessMaker\ChangeLog\ChangeLog;
|
use ProcessMaker\ChangeLog\ChangeLog;
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
use ProcessMaker\BusinessModel\Process as BmProcess;
|
||||||
use ProcessMaker\Core\Installer;
|
use ProcessMaker\Core\Installer;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
use ProcessMaker\Plugins\Adapters\PluginAdapter;
|
use ProcessMaker\Plugins\Adapters\PluginAdapter;
|
||||||
@@ -4596,4 +4597,26 @@ class WorkspaceTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync JSON definition of the Forms with Input Documents information
|
||||||
|
*/
|
||||||
|
public function syncFormsWithInputDocumentInfo() {
|
||||||
|
// Initialize Propel and instance the required classes
|
||||||
|
$this->initPropel(true);
|
||||||
|
$processInstance = new Process();
|
||||||
|
$bmProcessInstance = new BmProcess();
|
||||||
|
$pmDynaform = new PmDynaform();
|
||||||
|
|
||||||
|
// Get all active processes
|
||||||
|
$processes = $processInstance->getAllProcesses(0, '');
|
||||||
|
foreach ($processes as $process) {
|
||||||
|
// Get all Input Documents from a process
|
||||||
|
$inputDocuments = $bmProcessInstance->getInputDocuments($process['PRO_UID']);
|
||||||
|
foreach ($inputDocuments as $inputDocument) {
|
||||||
|
// Sync JSON definition of the Forms
|
||||||
|
$pmDynaform->synchronizeInputDocument($process['PRO_UID'], $inputDocument);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user