Merge remote branch 'upstream/master'
This commit is contained in:
@@ -14,12 +14,70 @@ class pmDynaform
|
||||
public $dyn_uid = null;
|
||||
public $record = null;
|
||||
public $app_data = null;
|
||||
public $items = array();
|
||||
public $data = array();
|
||||
public $variables = array();
|
||||
|
||||
public function __construct($dyn_uid, $app_data)
|
||||
{
|
||||
$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->variables[$row["VAR_NAME"]] = $rows2;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDynaform()
|
||||
@@ -41,6 +99,78 @@ class pmDynaform
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -50,7 +180,8 @@ class pmDynaform
|
||||
public function printView($pm_run_outside_main_app, $application)
|
||||
{
|
||||
ob_clean();
|
||||
|
||||
$this->mergeDynContentAppData($application, $this->items);
|
||||
|
||||
$a = $this->clientToken();
|
||||
$clientToken = array(
|
||||
"accessToken" => $a["access_token"],
|
||||
@@ -78,7 +209,8 @@ class pmDynaform
|
||||
public function printEdit($pm_run_outside_main_app, $application, $headData, $step_mode = 'EDIT')
|
||||
{
|
||||
ob_clean();
|
||||
|
||||
$this->mergeDynContentAppData($application, $this->items);
|
||||
|
||||
$a = $this->clientToken();
|
||||
$clientToken = array(
|
||||
"accessToken" => $a["access_token"],
|
||||
|
||||
@@ -392,30 +392,56 @@ function getDynaformsVars ($sProcessUID, $bSystemVars = true, $bIncMulSelFields
|
||||
if ($bIncMulSelFields != 0) {
|
||||
$aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields );
|
||||
}
|
||||
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 );
|
||||
// getting bpmn projects
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(BpmnProjectPeer::PRJ_UID);
|
||||
$oCriteria->add(BpmnProjectPeer::PRJ_UID, $sProcessUID);
|
||||
$oDataset = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
|
||||
$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;
|
||||
$row = $oDataset->getRow();
|
||||
if (isset($row["PRJ_UID"])) {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_UID);
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_NAME);
|
||||
$oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_TYPE);
|
||||
$oCriteria->add(ProcessVariablesPeer::PRJ_UID, $sProcessUID);
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -184,47 +184,6 @@ if (isset($_POST["PRO_FILENAME"]) &&
|
||||
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;
|
||||
|
||||
$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');
|
||||
if (uploader.getForm().isValid()) {
|
||||
uploader.getForm().submit({
|
||||
url: 'processes_Import_Ajax',
|
||||
url: 'processes_Import_Bpmn',
|
||||
waitMsg: _('ID_UPLOADING_PROCESS_FILE'),
|
||||
waitTitle: " ",
|
||||
success: function (o, resp) {
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user