Merge remote branch 'upstream/master'
This commit is contained in:
@@ -14,12 +14,70 @@ class pmDynaform
|
|||||||
public $dyn_uid = null;
|
public $dyn_uid = null;
|
||||||
public $record = null;
|
public $record = null;
|
||||||
public $app_data = null;
|
public $app_data = null;
|
||||||
|
public $items = array();
|
||||||
|
public $data = array();
|
||||||
|
public $variables = array();
|
||||||
|
|
||||||
public function __construct($dyn_uid, $app_data)
|
public function __construct($dyn_uid, $app_data)
|
||||||
{
|
{
|
||||||
$this->dyn_uid = $dyn_uid;
|
$this->dyn_uid = $dyn_uid;
|
||||||
$this->app_data = $app_data;
|
$this->app_data = $app_data;
|
||||||
$this->getDynaform();
|
$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->variables[$row["VAR_NAME"]] = $rows2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDynaform()
|
public function getDynaform()
|
||||||
@@ -41,6 +99,78 @@ class pmDynaform
|
|||||||
|
|
||||||
return $this->record;
|
return $this->record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function searchValues($varName, $value)
|
||||||
|
{
|
||||||
|
if (!$varName || !isset($this->variables[$varName])) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
$options = $this->variables[$varName];
|
||||||
|
foreach ($options as $valueOptions) {
|
||||||
|
if ($valueOptions[0] === $value) {
|
||||||
|
return $valueOptions[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function mergeAppData($app_uid, &$items)
|
||||||
|
{
|
||||||
|
foreach ($items as $key => $value) {
|
||||||
|
if (is_array($items[$key])) {
|
||||||
|
$this->mergeAppData($app_uid, $items[$key]);
|
||||||
|
} else {
|
||||||
|
if (isset($this->data[$items[$key]->name])) {
|
||||||
|
if ($items[$key]->type === "grid") {
|
||||||
|
$rows = $this->data[$items[$key]->name];
|
||||||
|
foreach ($rows as $keyRow => $row) {
|
||||||
|
$newRow = array();
|
||||||
|
foreach ($row as $keyCelda => $celda) {
|
||||||
|
array_push($newRow, array(
|
||||||
|
"value" => $celda,
|
||||||
|
"label" => $this->searchValues($keyCelda, $celda)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$rows[$keyRow] = $newRow;
|
||||||
|
}
|
||||||
|
$items[$key]->rows = count($rows);
|
||||||
|
$items[$key]->data = $rows;
|
||||||
|
}
|
||||||
|
if ($items[$key]->type !== "grid") {
|
||||||
|
$items[$key]->data = array(
|
||||||
|
"value" => $this->data[$items[$key]->name],
|
||||||
|
"label" => $this->searchValues($items[$key]->name, $this->data[$items[$key]->name])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($items[$key]->options) && isset($this->variables[$items[$key]->name])) {
|
||||||
|
$options = $this->variables[$items[$key]->name];
|
||||||
|
$n = count($options);
|
||||||
|
for ($i = 0; $i < $n; $i++) {
|
||||||
|
$options[$i] = array(
|
||||||
|
"value" => $options[$i][0],
|
||||||
|
"label" => $options[$i][1]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$items[$key]->options = $options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mergeDynContentAppData($app_uid, &$items)
|
||||||
|
{
|
||||||
|
$dynContent = G::json_decode($this->record["DYN_CONTENT"]);
|
||||||
|
if (isset($dynContent->items)) {
|
||||||
|
$this->items = $dynContent->items[0]->items;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mergeAppData($app_uid, &$items);
|
||||||
|
$dynContent->items[0]->items = $this->items;
|
||||||
|
|
||||||
|
$a = G::json_encode($dynContent);
|
||||||
|
$a = str_replace("\/", "/", $a);
|
||||||
|
$this->record["DYN_CONTENT"] = $a;
|
||||||
|
}
|
||||||
|
|
||||||
public function isResponsive()
|
public function isResponsive()
|
||||||
{
|
{
|
||||||
@@ -50,7 +180,8 @@ class pmDynaform
|
|||||||
public function printView($pm_run_outside_main_app, $application)
|
public function printView($pm_run_outside_main_app, $application)
|
||||||
{
|
{
|
||||||
ob_clean();
|
ob_clean();
|
||||||
|
$this->mergeDynContentAppData($application, $this->items);
|
||||||
|
|
||||||
$a = $this->clientToken();
|
$a = $this->clientToken();
|
||||||
$clientToken = array(
|
$clientToken = array(
|
||||||
"accessToken" => $a["access_token"],
|
"accessToken" => $a["access_token"],
|
||||||
@@ -78,7 +209,8 @@ class pmDynaform
|
|||||||
public function printEdit($pm_run_outside_main_app, $application, $headData, $step_mode = 'EDIT')
|
public function printEdit($pm_run_outside_main_app, $application, $headData, $step_mode = 'EDIT')
|
||||||
{
|
{
|
||||||
ob_clean();
|
ob_clean();
|
||||||
|
$this->mergeDynContentAppData($application, $this->items);
|
||||||
|
|
||||||
$a = $this->clientToken();
|
$a = $this->clientToken();
|
||||||
$clientToken = array(
|
$clientToken = array(
|
||||||
"accessToken" => $a["access_token"],
|
"accessToken" => $a["access_token"],
|
||||||
|
|||||||
@@ -392,30 +392,56 @@ function getDynaformsVars ($sProcessUID, $bSystemVars = true, $bIncMulSelFields
|
|||||||
if ($bIncMulSelFields != 0) {
|
if ($bIncMulSelFields != 0) {
|
||||||
$aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields );
|
$aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields );
|
||||||
}
|
}
|
||||||
require_once 'classes/model/Dynaform.php';
|
// getting bpmn projects
|
||||||
$oCriteria = new Criteria( 'workflow' );
|
$oCriteria = new Criteria('workflow');
|
||||||
$oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME );
|
$oCriteria->addSelectColumn(BpmnProjectPeer::PRJ_UID);
|
||||||
$oCriteria->add( DynaformPeer::PRO_UID, $sProcessUID );
|
$oCriteria->add(BpmnProjectPeer::PRJ_UID, $sProcessUID);
|
||||||
$oCriteria->add( DynaformPeer::DYN_TYPE, 'xmlform' );
|
$oDataset = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
|
||||||
$oDataset = DynaformPeer::doSelectRS( $oCriteria );
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
while ($aRow = $oDataset->getRow()) {
|
$row = $oDataset->getRow();
|
||||||
if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) {
|
if (isset($row["PRJ_UID"])) {
|
||||||
$G_FORM = new Form( $aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG );
|
$oCriteria = new Criteria('workflow');
|
||||||
if (($G_FORM->type == 'xmlform') || ($G_FORM->type == '')) {
|
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_UID);
|
||||||
foreach ($G_FORM->fields as $k => $v) {
|
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_NAME);
|
||||||
if (! in_array( $v->type, $aInvalidTypes )) {
|
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_TYPE);
|
||||||
if (! in_array( $k, $aFieldsNames )) {
|
$oCriteria->add(ProcessVariablesPeer::PRJ_UID, $sProcessUID);
|
||||||
$aFields[] = array ('sName' => $k,'sType' => $v->type,'sLabel' => ($v->type != 'grid' ? $v->label : '[ ' . G::LoadTranslation( 'ID_GRID' ) . ' ]')
|
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||||
);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$aFieldsNames[] = $k;
|
while ($oDataset->next()) {
|
||||||
|
$row = $oDataset->getRow();
|
||||||
|
array_push($aFields, array(
|
||||||
|
"sName" => $row["VAR_NAME"],
|
||||||
|
"sType" => $row["VAR_FIELD_TYPE"],
|
||||||
|
"sLabel" => $row["VAR_NAME"] . " [" . $row["VAR_FIELD_TYPE"] . "]"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
require_once 'classes/model/Dynaform.php';
|
||||||
|
$oCriteria = new Criteria( 'workflow' );
|
||||||
|
$oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME );
|
||||||
|
$oCriteria->add( DynaformPeer::PRO_UID, $sProcessUID );
|
||||||
|
$oCriteria->add( DynaformPeer::DYN_TYPE, 'xmlform' );
|
||||||
|
$oDataset = DynaformPeer::doSelectRS( $oCriteria );
|
||||||
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||||
|
$oDataset->next();
|
||||||
|
while ($aRow = $oDataset->getRow()) {
|
||||||
|
if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) {
|
||||||
|
$G_FORM = new Form( $aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG );
|
||||||
|
if (($G_FORM->type == 'xmlform') || ($G_FORM->type == '')) {
|
||||||
|
foreach ($G_FORM->fields as $k => $v) {
|
||||||
|
if (! in_array( $v->type, $aInvalidTypes )) {
|
||||||
|
if (! in_array( $k, $aFieldsNames )) {
|
||||||
|
$aFields[] = array ('sName' => $k,'sType' => $v->type,'sLabel' => ($v->type != 'grid' ? $v->label : '[ ' . G::LoadTranslation( 'ID_GRID' ) . ' ]')
|
||||||
|
);
|
||||||
|
$aFieldsNames[] = $k;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$oDataset->next();
|
||||||
}
|
}
|
||||||
$oDataset->next();
|
|
||||||
}
|
}
|
||||||
return $aFields;
|
return $aFields;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,47 +184,6 @@ if (isset($_POST["PRO_FILENAME"]) &&
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_FILES["PROCESS_FILENAME"]) &&
|
|
||||||
pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION) == "bpmn"
|
|
||||||
) {
|
|
||||||
$createMode = $_REQUEST["createMode"];
|
|
||||||
$name = pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_FILENAME);
|
|
||||||
$data = array(
|
|
||||||
"type" => "bpmnProject",
|
|
||||||
"PRO_TITLE" => $name,
|
|
||||||
"PRO_DESCRIPTION" => "",
|
|
||||||
"PRO_CATEGORY" => "",
|
|
||||||
"PRO_CREATE_USER" => $_SESSION['USER_LOGGED']
|
|
||||||
);
|
|
||||||
$stringBpmn = base64_encode(file_get_contents($_FILES["PROCESS_FILENAME"]["tmp_name"]));
|
|
||||||
try {
|
|
||||||
if ($createMode === "overwrite") {
|
|
||||||
$process = Process::getByProTitle($data["PRO_TITLE"]);
|
|
||||||
if ($process !== null) {
|
|
||||||
$oProcess = new Process();
|
|
||||||
$oProcess->remove($process["PRO_UID"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($createMode === "rename") {
|
|
||||||
$data["PRO_TITLE"] = Process::getNextTitle($data["PRO_TITLE"]);
|
|
||||||
}
|
|
||||||
$project = new \ProcessMaker\Project\Adapter\WorkflowBpmn($data);
|
|
||||||
$result = array(
|
|
||||||
"success" => true,
|
|
||||||
"catchMessage" => "",
|
|
||||||
"prj_uid" => $project->getUid(),
|
|
||||||
"stringBpmn" => $stringBpmn
|
|
||||||
);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$result = array(
|
|
||||||
"success" => true,
|
|
||||||
"catchMessage" => $e->getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
echo G::json_encode($result);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$action = isset( $_REQUEST['ajaxAction'] ) ? $_REQUEST['ajaxAction'] : null;
|
$action = isset( $_REQUEST['ajaxAction'] ) ? $_REQUEST['ajaxAction'] : null;
|
||||||
|
|
||||||
$importer = new XmlImporter();
|
$importer = new XmlImporter();
|
||||||
|
|||||||
53
workflow/engine/methods/processes/processes_Import_Bpmn.php
Normal file
53
workflow/engine/methods/processes/processes_Import_Bpmn.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
ini_set("max_execution_time", 0);
|
||||||
|
|
||||||
|
if (isset($_FILES["PROCESS_FILENAME"]) &&
|
||||||
|
pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION) == "bpmn"
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
$createMode = $_REQUEST["createMode"];
|
||||||
|
$name = pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_FILENAME);
|
||||||
|
$data = array(
|
||||||
|
"type" => "bpmnProject",
|
||||||
|
"PRO_TITLE" => $name,
|
||||||
|
"PRO_DESCRIPTION" => "",
|
||||||
|
"PRO_CATEGORY" => "",
|
||||||
|
"PRO_CREATE_USER" => $_SESSION['USER_LOGGED']
|
||||||
|
);
|
||||||
|
$stringBpmn = base64_encode(file_get_contents($_FILES["PROCESS_FILENAME"]["tmp_name"]));
|
||||||
|
if ($createMode === "overwrite") {
|
||||||
|
$process = Process::getByProTitle($data["PRO_TITLE"]);
|
||||||
|
if ($process !== null) {
|
||||||
|
$oProcess = new Process();
|
||||||
|
$oProcess->remove($process["PRO_UID"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($createMode === "rename") {
|
||||||
|
$data["PRO_TITLE"] = Process::getNextTitle($data["PRO_TITLE"]);
|
||||||
|
}
|
||||||
|
$project = new \ProcessMaker\Project\Adapter\WorkflowBpmn($data);
|
||||||
|
$result = array(
|
||||||
|
"success" => true,
|
||||||
|
"catchMessage" => "",
|
||||||
|
"prj_uid" => $project->getUid(),
|
||||||
|
"stringBpmn" => $stringBpmn,
|
||||||
|
"createMode" => $createMode
|
||||||
|
);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$result = array(
|
||||||
|
"success" => "confirm",
|
||||||
|
"catchMessage" => $e->getMessage(),
|
||||||
|
"createMode" => $createMode
|
||||||
|
);
|
||||||
|
}
|
||||||
|
echo G::json_encode($result);
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
|
$result = array(
|
||||||
|
"success" => "error",
|
||||||
|
"catchMessage" => G::LoadTranslation("ID_FILE_UPLOAD_INCORRECT_EXTENSION")
|
||||||
|
);
|
||||||
|
echo G::json_encode($result);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
@@ -1440,12 +1440,24 @@ importProcessBpmnSubmit = function () {
|
|||||||
var uploader = Ext.getCmp('uploader');
|
var uploader = Ext.getCmp('uploader');
|
||||||
if (uploader.getForm().isValid()) {
|
if (uploader.getForm().isValid()) {
|
||||||
uploader.getForm().submit({
|
uploader.getForm().submit({
|
||||||
url: 'processes_Import_Ajax',
|
url: 'processes_Import_Bpmn',
|
||||||
waitMsg: _('ID_UPLOADING_PROCESS_FILE'),
|
waitMsg: _('ID_UPLOADING_PROCESS_FILE'),
|
||||||
waitTitle: " ",
|
waitTitle: " ",
|
||||||
success: function (o, resp) {
|
success: function (o, resp) {
|
||||||
var resp_ = Ext.util.JSON.decode(resp.response.responseText);
|
var resp_ = Ext.util.JSON.decode(resp.response.responseText);
|
||||||
if (resp_.catchMessage !== "") {
|
if (resp_.success === "error") {
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: '',
|
||||||
|
msg: resp_.catchMessage,
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
animEl: 'mb9',
|
||||||
|
fn: function () {
|
||||||
|
},
|
||||||
|
icon: Ext.MessageBox.ERROR
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (resp_.success === "confirm") {
|
||||||
windowbpmnoption.show();
|
windowbpmnoption.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user