Ext.onReady ( function() {
workflow = new MyWorkflow("paintarea");
workflow.setEnableSmoothFigureHandling(true);
workflow.scrollArea.width = 2000;
//For Undo and Redo Options
// workflow.getCommandStack().addCommandStackEventListener(new commandListener());
//Getting process id from the URL using getUrlvars function
var pro_uid = getUrlVars();
if(typeof pro_uid != 'undefined')
{
Ext.Ajax.request({
url: 'openProcess.php?PRO_UID=' + pro_uid,
success: function(response) {
var shapesData = createShapes(response.responseText,this);
createConnection(shapesData);
},
failure: function(){
Ext.Msg.alert ('Failure');
}
});
//load all the Information related to the process
// var urlparams = '?action=load&data={"uid":"'+ pro_uid +'"}';
// Ext.Ajax.request({
// url: "processes_Ajax.php"+ urlparams,
// success: function(response) {
// this.workflow.processInfo = Ext.util.JSON.decode(response.responseText);
// },
// failure: function(){
// Ext.Msg.alert ('Failure');
// }
// });
//Get All the processes
// var urlparams = '?action=getProcesses';
// Ext.Ajax.request({
// url: "processes_Ajax.php"+ urlparams,
// success: function(response) {
// this.workflow.processName = Ext.util.JSON.decode(response.responseText);
// },
// failure: function(){
// Ext.Msg.alert ('Failure');
// }
// });
}
/**********************************************************************************
*
* Do the Ext (Yahoo UI) Stuff
*
**********************************************************************************/
var west= {
xtype :"panel",
title: 'Palette',
region: 'west',
split: false,
width: 75,
collapsible: false,
margins:'3 0 3 3',
cmargins:'3 3 3 3',
items:{
html:'

\n\

\n\

\n\

\n\

\n\

\n\

\n\

\n\

\n\

\n\

\n\
'
}
};
var north= {
xtype : "panel",
initialSize: 60,
split:false,
titlebar: false,
collapsible: false,
animate: false,
region : "north"
};
var south= {
xtype : "panel",
initialSize: 120,
height: 100,
split:true,
titlebar: false,
collapsible: true,
autoScroll:true,
animate: true,
region : "south",
items: {
region: 'center',
xtype: 'tabpanel',
items: [{
title: 'Properties',
html: 'Properties'
},
{
title: 'Debug Console',
html: 'Debug Console'
}]
}
};
var center= {
width:100,
height:200,
xtype : "panel",
titlebar: true,
title : 'BPMN Processmap',
autoScroll:true,
fitToFrame:true,
region : "center"
};
var processObj = new ProcessOptions();
var main = new Ext.Panel({
tbar: [
{
text: 'Save',
cls: 'x-btn-text-icon',
handler: function() {
saveProcess();
}
},
{
text:'Save as'
},
{
text:'Undo',
handler: function() {
workflow.getCommandStack().undo();
}
},
{
text:'Redo',
handler: function() {
workflow.getCommandStack().redo();
}
},
{
xtype: 'tbsplit',
text: 'Process',
menu: new Ext.menu.Menu({
items: [{
text : 'Dynaform',
handler : function() {
processObj.addDynaform();
}
},
{
text: 'Input Document',
handler : function() {
processObj.addInputDoc();
}
},{
text: 'Output Document'
},{text: 'Trigger'},{text: 'Report Table'},{text: 'Database Connection'},{text: 'Cases Scheduler'}]
})
},
{
text:'Zoom In',
handler: function() {
var figures = workflow.getDocument().getFigures();
for(f = 0;f= 6) {
// len = 1.5;
var padleft = 0.12 * fig.width;
var padtop = 0.32 * fig.height - 3;
fig.rectWidth = fig.width - 2 * padleft;
}
else {
padleft = 0.1 * fig.width;
padtop = 0.09 * fig.height - 3;
fig.rectWidth = fig.width - 2 * padleft;
}
var rectheight = fig.height - 2*padtop;
if(typeof fig.size == 'undefined')
fig.size = fig.bpmnText.ftSz.substr(0,fig.bpmnText.ftSz.length-2);
else
fig.size = parseInt(fig.size) + 4;
eval("fig.bpmnText.setFont('verdana','"+fig.size+"px', Font.PLAIN)");
fig.bpmnText.drawStringRect(fig.taskName, padleft, padtop, fig.rectWidth, rectheight, 'center');
fig.bpmnText.paint();
}
else if(fig.type == 'bpmnAnnotation')
{
fig.bpmnText.clear();
var text = fig.annotationName;
len = Math.ceil(text.length/16);
if(text.length < 19)
{
len = 1.5;
if(text.length > 9)
fig.rectWidth = text.length*8;
else
fig.rectWidth = 48;
}
else
fig.rectWidth = 150;
if(typeof fig.size == 'undefined')
fig.size = fig.bpmnText.ftSz.substr(0,fig.bpmnText.ftSz.length-2);
else
fig.size = parseInt(fig.size) + 4;
eval("fig.bpmnText.setFont('verdana','"+fig.size+"px', Font.PLAIN)");
fig.bpmnText.drawStringRect(text,20,20,fig.rectWidth,'left');
fig.bpmnText.paint();
}
}
}
},
{
text:'Zoom Out',
handler: function() {
var figures = workflow.getDocument().getFigures();
for(f = 0;f'center region'
var centerRegionId = main.items.items[2].body.id;
canvas = Ext.get(centerRegionId);
//Context Menu of ProcessMap
ProcessMapObj = new ProcessMapContext();
contextCanvasMenu = new Ext.menu.Menu({
items: [{
text: 'Edit Process',
handler: ProcessMapObj.editProcess,
icon: '/skins/ext/images/gray/shapes/more.gif',
scope: this
}, {
text: 'Export Process',
handler: ProcessMapObj.exportProcess,
scope: this
}, {
text: 'Add Task',
handler: ProcessMapObj.addTask,
scope: this
}, {
text: 'Add Subprocess',
handler: workflow.subProcess,
scope: this
},/* {
text: 'Horizontal Line',
handler: ProcessMapObj.horiLine,
scope: this
}, {
text: 'Vertical Line',
handler: ProcessMapObj.vertiLine,
scope: this
}, {
text: 'Delete All Lines',
handler: ProcessMapObj.delLines,
scope: this
}, */{
text: 'Process Permission',
handler: ProcessMapObj.processPermission,
scope: this
},{
text: 'Case Tracker',
handler: ProcessMapObj.caseTracker,
scope: this
}, {
text: 'Process File Manager',
menu: { // <-- submenu by nested config object
items: [
// stick any markup in a menu
{
text: 'mailTemplates',
handler: ProcessMapObj.processFileManager
},
{
text: 'public',
handler: ProcessMapObj.processFileManager
}
]
}
}]
});
canvas.on('contextmenu', function(e) {
e.stopEvent();
this.workflow.contextX = e.xy[0];
this.workflow.contextY = e.xy[1];
var pmosExtObj = new pmosExt();
//Load all the process Data
pmosExtObj.loadEditProcess(this);
pmosExtObj.loadProcessCategory(this);
this.contextCanvasMenu.showAt(e.getXY());
}, this);
canvas.on('click', function(e) {
e.stopEvent();
this.workflow.contextClicked = false;
if(this.workflow.currentSelection != null)
this.workflow.disablePorts(this.workflow.currentSelection);
//Removes Flow menu
this.workflow.setCurrentSelection(null);
}, this);
var simpleToolbar = new Ext.Toolbar('toolbar');
simpleToolbar.addButton({
text: 'Save',
cls: 'x-btn-text-icon scroll-bottom'
});
simpleToolbar.addButton({
text: 'Save As',
cls: 'x-btn-text-icon scroll-bottom'
});
simpleToolbar.addButton({
text: 'Undo',
cls: 'x-btn-text-icon'
});
simpleToolbar.addButton({
text: 'Redo',
cls: 'x-btn-text-icon'
});
var menu = new FlowMenu(workflow);
workflow.addSelectionListener(menu);
workflow.scrollArea = document.getElementById(centerRegionId).parentNode;
var dragsource=new Ext.dd.DragSource("x-shapes-task", {
ddGroup:'TreeDD',
dragData:{
name: "bpmnTask"
}
});
var dragsource=new Ext.dd.DragSource("x-shapes-startEvent", {
ddGroup:'TreeDD',
dragData:{
name: "bpmnEventEmptyStart"
}
});
var dragsource=new Ext.dd.DragSource("x-shapes-interEvent", {
ddGroup:'TreeDD',
dragData:{
name: "bpmnEventEmptyInter"
}
});
var dragsource=new Ext.dd.DragSource("x-shapes-endEvent", {
ddGroup:'TreeDD',
dragData:{
name: "bpmnEventEmptyEnd"
}
});
var dragsource=new Ext.dd.DragSource("x-shapes-gateways", {
ddGroup:'TreeDD',
dragData:{
name: "bpmnGatewayExclusiveData"
}
});
var dragsource=new Ext.dd.DragSource("x-shapes-dataobject", {
ddGroup:'TreeDD',
dragData:{
name: "bpmnDataobject"
}
});
var dragsource=new Ext.dd.DragSource("x-shapes-pool", {
ddGroup:'TreeDD',
dragData:{
name: "bpmnPool"
}
});
var dragsource=new Ext.dd.DragSource("x-shapes-annotation", {
ddGroup:'TreeDD',
dragData:{
name: "bpmnAnnotation"
}
});
var droptarget=new Ext.dd.DropTarget(centerRegionId,{
ddGroup:'TreeDD'
});
//Creating Pool
var oPool = new bpmnPool(workflow);
//workflow.addFigure(oPool,100,70);
workflow.taskNo= 0; //Initializing Count for the bpmnTask
var count = 0;
this.taskName='';
droptarget.notifyDrop=function(dd, e, data)
{
if(data.name)
{
var xOffset = workflow.getAbsoluteX();
var yOffset = workflow.getAbsoluteY();
if(data.name == 'bpmnTask')
{
count = ++workflow.taskNo; //Incrementing Task No and assigning it to a local variable
workflow.boundaryEvent = false;
workflow.taskName = 'Task '+count;
}
NewShape = eval("new "+data.name+"(workflow)");
NewShape.x = e.xy[0];
NewShape.y = e.xy[1];
NewShape.actiontype = 'addTask';
if(data.name == 'bpmnAnnotation')
{
NewShape.actiontype = 'addText';
workflow.saveShape(NewShape); //Saving task when user drags and drops it
}
if(data.name == 'bpmnTask')
{
NewShape.actiontype = 'addTask';
workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it
NewShape.taskName = workflow.taskName;
}
var scrollLeft = workflow.getScrollLeft();
var scrollTop = workflow.getScrollTop();
workflow.addFigure(NewShape,e.xy[0]-xOffset+scrollLeft,e.xy[1]-yOffset+scrollTop);
return true;
}
}
function createConnection(shapes)
{
//var totaltask = shapes[0].length; //shapes[0] is an array for all the tasks
//var totalgateways = shapes[1].length; //shapes[1] is an array for all the gateways
//var totalevents = shapes[2].length; //shapes[2] is an array for all the events
var totalroutes = shapes.routes.length; //shapes[3] is an array for all the routes
for(var i=0;i<=totalroutes-1;i++)
{
var sourceid = shapes.routes[i][1]; //getting source id for connection from Routes array
var targetid = shapes.routes[i][2]; //getting target id for connection from Routes array
//After creating all the shapes, check one by one shape id
for(var conn =0; conn < this.workflow.figures.data.length ; conn++)
{
if(typeof this.workflow.figures.data[conn] === 'object')
{
if(sourceid == this.workflow.figures.data[conn].id){
sourceObj = this.workflow.figures.data[conn];
}
}
}
for(var conn =0; conn < this.workflow.figures.data.length ; conn++)
{
if(typeof this.workflow.figures.data[conn] === 'object')
{
if(targetid == '-1')
{
targetObj = eval("new bpmnEventEmptyEnd (this.workflow)");
this.workflow.addFigure(targetObj,sourceObj.x+67,sourceObj.y+60);
break;
}
else if(targetid == this.workflow.figures.data[conn].id ){
targetObj = this.workflow.figures.data[conn];
}
}
}
//Making Connections
var connObj = new DecoratedConnection();
connObj.setSource(sourceObj.output1);
connObj.setTarget(targetObj.input2);
connObj.id = shapes.routes[i][0];
this.workflow.addFigure(connObj);
}
}
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
var pro_uid = vars["PRO_UID"];
return pro_uid;
}
function createShapes(stringData,_4562)
{
var responsearray = stringData.split("|");
var jsonstring = new Array();
var shapes = new Array();
//var param = new Array();
var shapeType = new Array();
for(var i=0; i<=responsearray.length-1;i++)
{
jsonstring[i] = responsearray[i].split(":");
var param = jsonstring[i][0].replace(" ","");
shapeType[i] = param;
switch(param)
{
case 'tasks':
shapes[param] = new Array();
shapes[param] = Ext.util.JSON.decode(jsonstring[i][1]);
break;
case 'gateways':
shapes[param] = new Array();
shapes[param] = Ext.util.JSON.decode(jsonstring[i][1]);
break;
case 'events':
shapes[param] = new Array();
shapes[param] = Ext.util.JSON.decode(jsonstring[i][1]);
break;
case 'annotations':
shapes[param] = new Array();
shapes[param] = Ext.util.JSON.decode(jsonstring[i][1]);
break;
case 'process':
shapes[param] = new Array();
shapes[param] = Ext.util.JSON.decode(jsonstring[i][1]);
break;
case 'subprocess':
shapes[param] = new Array();
shapes[param] = Ext.util.JSON.decode(jsonstring[i][1]);
break;
case 'routes':
shapes[param] = new Array();
shapes[param] = Ext.util.JSON.decode(jsonstring[i][1]);
break;
}
}
//Create all shapes
for(var j=0;j< shapeType.length;j++)
{
// _4562.workflow.taskNo=0;
switch(shapeType[j])
{
case 'tasks':
for(var k=0;k"+msg;
}
function saveProcess()
{
// console.dir(this.workflow);
var tasks = new Array();
var events = new Array();
var gateways = new Array();
var annotations = new Array();
var subprocess = new Array();
var l=0;
var m=0;
var n=0;
var p=0;
var r=0;
for(var c = 0; c