PM-1429
This commit is contained in:
@@ -586,6 +586,51 @@ class Process extends BaseProcess
|
||||
return ((int)($aRow["NUM_REC"]) > 0)? true : false;
|
||||
}
|
||||
|
||||
public static function getByProTitle($PRO_TITLE) {
|
||||
$oCriteria = new Criteria("workflow");
|
||||
|
||||
$oCriteria->addSelectColumn(ContentPeer::CON_ID);
|
||||
|
||||
$oCriteria->add(ContentPeer::CON_CATEGORY, 'PRO_TITLE');
|
||||
$oCriteria->add(ContentPeer::CON_LANG, SYS_LANG);
|
||||
$oCriteria->add(ContentPeer::CON_VALUE, $PRO_TITLE);
|
||||
$oDataset = ContentPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
$oProcess = new Process();
|
||||
return $oProcess->load($aRow["CON_ID"]);
|
||||
}
|
||||
|
||||
public static function getNextTitle($PRO_TITLE) {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
|
||||
$oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
|
||||
|
||||
$oCriteria->add(ContentPeer::CON_CATEGORY, 'PRO_TITLE');
|
||||
$oCriteria->add(ContentPeer::CON_LANG, SYS_LANG);
|
||||
$oCriteria->add(ContentPeer::CON_VALUE, $PRO_TITLE . '-%', Criteria::LIKE);
|
||||
$oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
|
||||
|
||||
$oDataset = ContentPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$data = array();
|
||||
$may = 0;
|
||||
while ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
$number = explode("-", $row["CON_VALUE"]);
|
||||
$number = $number[count($number) - 1] + 0;
|
||||
if ($number > $may) {
|
||||
$may = $number;
|
||||
}
|
||||
$row["CON_VALUE"] = $number;
|
||||
$data[] = $row;
|
||||
}
|
||||
return $PRO_TITLE . "-" . ($may + 1);
|
||||
}
|
||||
|
||||
public function getAllProcessesCount ()
|
||||
{
|
||||
$c = $this->tmpCriteria;
|
||||
|
||||
@@ -26,6 +26,7 @@ class Designer extends Controller
|
||||
$proUid = isset($httpData->prj_uid) ? $httpData->prj_uid : '';
|
||||
$appUid = isset($httpData->app_uid) ? $httpData->app_uid : '';
|
||||
$proReadOnly = isset($httpData->prj_readonly) ? $httpData->prj_readonly : 'false';
|
||||
$stringBpmn = isset($httpData->stringBpmn) ? '<textarea id="stringBpmn" style="display:none">' . base64_decode($httpData->stringBpmn) . '</textarea>' : '';
|
||||
$client = $this->getClientCredentials();
|
||||
$authCode = $this->getAuthorizationCode($client);
|
||||
$debug = false; //System::isDebugMode();
|
||||
@@ -56,6 +57,7 @@ class Designer extends Controller
|
||||
|
||||
$this->setVar('prj_uid', $proUid);
|
||||
$this->setVar('app_uid', $appUid);
|
||||
$this->setVar('stringBpmn', $stringBpmn);
|
||||
$this->setVar('prj_readonly', $proReadOnly);
|
||||
$this->setVar('credentials', base64_encode(json_encode($clientToken)));
|
||||
$this->setVar('isDebugMode', $debug);
|
||||
|
||||
@@ -184,6 +184,45 @@ 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"]);
|
||||
$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();
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
</head>
|
||||
<body onresize="resizingFrame();">
|
||||
|
||||
{$stringBpmn}
|
||||
|
||||
<div class="ui-layout-north">
|
||||
<section class="navBar" id="idNavBar">
|
||||
|
||||
@@ -306,6 +306,14 @@ Ext.onReady(function(){
|
||||
importProcessGlobal.processFileType = "pm";
|
||||
importProcess();
|
||||
}
|
||||
},{
|
||||
text: _('ID_IMPORT') + " BPMN",
|
||||
iconCls: 'silk-add',
|
||||
icon: '/images/import.gif',
|
||||
handler : function(){
|
||||
importProcessGlobal.processFileType = "bpmn";
|
||||
importProcessBpmn();
|
||||
}
|
||||
},{
|
||||
xtype: 'tbfill'
|
||||
},{
|
||||
@@ -1303,6 +1311,172 @@ importProcess = function()
|
||||
});
|
||||
w.show();
|
||||
}
|
||||
|
||||
importProcessBpmn = function ()
|
||||
{
|
||||
var w = new Ext.Window({
|
||||
id: 'import_process_bpmn',
|
||||
title: _('ID_IMPORT_PROCESS'),
|
||||
width: 420,
|
||||
height: 130,
|
||||
modal: true,
|
||||
autoScroll: false,
|
||||
maximizable: false,
|
||||
resizable: false,
|
||||
items: [
|
||||
new Ext.FormPanel({
|
||||
id: 'uploader',
|
||||
fileUpload: true,
|
||||
width: 400,
|
||||
height: 90,
|
||||
frame: true,
|
||||
title: _('ID_IMPORT_PROCESS'),
|
||||
header: false,
|
||||
autoHeight: false,
|
||||
bodyStyle: 'padding: 10px 10px 0 10px;',
|
||||
labelWidth: 50,
|
||||
defaults: {
|
||||
anchor: '90%',
|
||||
allowBlank: false,
|
||||
msgTarget: 'side'
|
||||
},
|
||||
items: [
|
||||
{
|
||||
name: 'ajaxAction',
|
||||
xtype: 'hidden',
|
||||
value: 'uploadFileNewProcess'
|
||||
}, {
|
||||
name: 'processFileType',
|
||||
xtype: 'hidden',
|
||||
value: importProcessGlobal.processFileType
|
||||
},{
|
||||
name: 'createMode',
|
||||
xtype: 'hidden',
|
||||
value: 'create'
|
||||
}, {
|
||||
xtype: 'fileuploadfield',
|
||||
id: 'form-file',
|
||||
emptyText: _('ID_SELECT_PROCESS_FILE'),
|
||||
fieldLabel: _('ID_LAN_FILE'),
|
||||
name: 'PROCESS_FILENAME',
|
||||
buttonText: '',
|
||||
buttonCfg: {
|
||||
iconCls: 'upload-icon'
|
||||
}
|
||||
}
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
text: _('ID_UPLOAD'),
|
||||
handler: function () {
|
||||
importProcessBpmnSubmit();
|
||||
}
|
||||
}, {
|
||||
text: _('ID_CANCEL'),
|
||||
handler: function () {
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
w.show();
|
||||
}
|
||||
|
||||
var windowbpmnoption = new Ext.Window({
|
||||
title: _('ID_IMPORT_PROCESS'),
|
||||
header: false,
|
||||
width: 420,
|
||||
height: 200,
|
||||
modal: true,
|
||||
autoScroll: false,
|
||||
maximizable: false,
|
||||
resizable: false,
|
||||
closeAction: 'hide',
|
||||
items: [
|
||||
{
|
||||
xtype: 'panel',
|
||||
border: false,
|
||||
bodyStyle: 'padding:15px;background-color:#e8e8e8;',
|
||||
items: [
|
||||
{
|
||||
xtype: 'box',
|
||||
autoEl: {
|
||||
tag: 'div',
|
||||
html: '<div style="margin-bottom:15px;background-color:#e8e8e8;"><img style="display:inline-block;vertical-align:top;" src="/images/ext/default/window/icon-warning.gif"/><div style="display:inline-block;width:338px;margin-left:5px;">' +
|
||||
_('ID_IMPORT_ALREADY_EXISTS_BPMN') + "<br><br>" + _('ID_IMPORT_ALREADY_EXISTS_BPMN_NOTE') +
|
||||
'</div></div>'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
text: _('ID_CREATE_NEW'),
|
||||
handler: function () {
|
||||
Ext.getCmp('uploader').getForm().setValues({"createMode": "rename"})
|
||||
importProcessBpmnSubmit();
|
||||
}
|
||||
}, {
|
||||
text: _('ID_OVERWRITE'),
|
||||
handler: function () {
|
||||
Ext.getCmp('uploader').getForm().setValues({"createMode": "overwrite"})
|
||||
importProcessBpmnSubmit();
|
||||
}
|
||||
}, {
|
||||
text: _('ID_CANCEL'),
|
||||
handler: function () {
|
||||
Ext.getCmp('import_process_bpmn').close();
|
||||
windowbpmnoption.hide();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
importProcessBpmnSubmit = function () {
|
||||
windowbpmnoption.hide();
|
||||
var uploader = Ext.getCmp('uploader');
|
||||
if (uploader.getForm().isValid()) {
|
||||
uploader.getForm().submit({
|
||||
url: 'processes_Import_Ajax',
|
||||
waitMsg: _('ID_UPLOADING_PROCESS_FILE'),
|
||||
waitTitle: " ",
|
||||
success: function (o, resp) {
|
||||
var resp_ = Ext.util.JSON.decode(resp.response.responseText);
|
||||
if (resp_.catchMessage !== "") {
|
||||
windowbpmnoption.show();
|
||||
return;
|
||||
}
|
||||
Ext.getCmp('import_process_bpmn').close();
|
||||
var stringxml = document.createElement("input");
|
||||
stringxml.type = "hidden";
|
||||
stringxml.name = "stringBpmn";
|
||||
stringxml.value = resp_.stringBpmn;
|
||||
var form = document.createElement("form");
|
||||
document.body.appendChild(form);
|
||||
form.appendChild(stringxml);
|
||||
form.style.display = "none";
|
||||
form.action = "../designer?prj_uid=" + resp_.prj_uid;
|
||||
form.method = "POST";
|
||||
form.submit();
|
||||
},
|
||||
failure: function (o, resp) {
|
||||
Ext.getCmp('import_process_bpmn').close();
|
||||
Ext.MessageBox.show({
|
||||
title: '',
|
||||
msg: resp.catchMessage,
|
||||
buttons: Ext.MessageBox.OK,
|
||||
animEl: 'mb9',
|
||||
fn: function () {
|
||||
},
|
||||
icon: Ext.MessageBox.ERROR
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function activeDeactive(){
|
||||
var rows = processesGrid.getSelectionModel().getSelections();
|
||||
|
||||
Reference in New Issue
Block a user