From 7ac86a8099cc6c2e82cb3997ae3f220900b929a9 Mon Sep 17 00:00:00 2001 From: Enrique Ponce de Leon Date: Mon, 28 Feb 2011 22:18:05 +0000 Subject: [PATCH] Change of Start Message Event Properties with Web Entries management. --- workflow/engine/classes/class.processMap.php | 37 +- workflow/engine/classes/model/Task.php | 19 + workflow/engine/controllers/webEntryProxy.php | 238 ++++++++ .../processes/processes_webEntryGenerate.php | 4 +- workflow/engine/templates/bpmn/pmosExt.js | 550 +++++++++--------- 5 files changed, 568 insertions(+), 280 deletions(-) create mode 100644 workflow/engine/controllers/webEntryProxy.php diff --git a/workflow/engine/classes/class.processMap.php b/workflow/engine/classes/class.processMap.php index 1bd91363d..b0a928729 100644 --- a/workflow/engine/classes/class.processMap.php +++ b/workflow/engine/classes/class.processMap.php @@ -2802,7 +2802,6 @@ class processMap { G::LoadClass('ArrayPeer'); $oCriteria = new Criteria('dbarray'); $oCriteria->setDBArrayTable('reports'); - //if ($TaskFields['TAS_ASSIGN_TYPE'] == 'BALANCED') { //$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_WebEntry', '', array('PRO_UID' => $sProcessUID, 'LANG' => SYS_LANG)); $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_WebEntryList', $oCriteria, array('PRO_UID' => $sProcessUID, 'LANG' => SYS_LANG)); @@ -2836,6 +2835,24 @@ class processMap { throw ($oError); } } + +/** + * webEntryByTask + * + * @param string $sProcessUID + * @return boolean true + * throw Exception $oError + */ +// function webEntryByTask($sProcessUID, $sEventUID) { +// $event = new Event(); +// $event->load($sEventUID); +// $task_uid = $event->getEvnTasUidTo(); +// $tasks = new Tasks(); +// $tasks->get +// $link = $sProcessUID.'/'.str_replace ( ' ', '_', str_replace ( '/', '_',$task_uid)); +// +// return $link; +// } /* * Return the supervisors dynaforms list criteria object @@ -4548,12 +4565,28 @@ class processMap { $oEvent = EventPeer::retrieveByPK($sEventUID); if (!is_null($oEvent)) { $oData = $oEvent->load($sEventUID); + $dynTitle = ''; + $dynUid = ''; + $task_name = ''; + $usr_uid_evn = $oEvent->getEvnConditions(); if($oData['EVN_ACTION'] != '' && $oData['EVN_ACTION'] != 'WEB_ENTRY') { require_once 'classes/model/Content.php'; + require_once 'classes/model/Task.php'; + require_once 'classes/model/Dynaform.php'; $oContent = new Content(); $dynTitle = $oContent->load('DYN_TITLE', '', $oData['EVN_ACTION'], 'en'); + $task_uid = $oEvent->getEvnTasUidTo(); + + $dyn = new Dynaform(); + $dyn->load($oData['EVN_ACTION']); + + $dynUid = $dyn->getDynUid(); + + $task = new Task(); + $task->load($task_uid); + $task_name = $task->getTasTitle(); if (G::is_https ()) $http = 'https://'; @@ -4581,7 +4614,7 @@ class processMap { } } } - $row [] = array ('W_LINK' => $arlink); + $row [] = array ('W_LINK' => $arlink,'DYN_TITLE'=>$dynTitle,'TAS_TITLE'=>$task_name, 'USR_UID'=>$usr_uid_evn, 'DYN_UID'=>$dynUid); $oJSON = new Services_JSON ( ); $tmpData = $oJSON->encode( $row ) ; $tmpData = str_replace("\\/","/",'{success:true,data:'.$tmpData.'}'); // unescape the slashes diff --git a/workflow/engine/classes/model/Task.php b/workflow/engine/classes/model/Task.php index 8f81667c8..5fd94f79c 100644 --- a/workflow/engine/classes/model/Task.php +++ b/workflow/engine/classes/model/Task.php @@ -582,4 +582,23 @@ public function kgetassigType($pro_uid, $tas){ return $aFields; } + + //Added by qennix + //Gets Starting Event of current task + function getStartingEvent(){ + require_once 'classes/model/Event.php'; + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(EventPeer::EVN_UID); + $oCriteria->add(EventPeer::EVN_TAS_UID_TO,$this->tas_uid); + $oCriteria->add(EventPeer::EVN_TYPE,'bpmnEventMessageStart'); + $oDataset = EventPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + if ($oDataset->next()){ + $row = $oDataset->getRow(); + $event_uid = $row['EVN_UID']; + }else{ + $event_uid = ''; + } + return $event_uid; + } } // Task diff --git a/workflow/engine/controllers/webEntryProxy.php b/workflow/engine/controllers/webEntryProxy.php new file mode 100644 index 000000000..9057c85f1 --- /dev/null +++ b/workflow/engine/controllers/webEntryProxy.php @@ -0,0 +1,238 @@ +PRO_UID; + $filename = $params->FILE_NAME; + $filename = $filename.'.php'; + $evn_uid = $params->EVN_UID; + + $event = new Event(); + + $editEvent = array(); + $editEvent['EVN_UID'] = $evn_uid; + $editEvent['EVN_ACTION'] = ''; + $editEvent['EVN_CONDITIONS'] = null; + $event->update($editEvent); + + unlink(PATH_DATA ."sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP. $pro_uid. PATH_SEP.$filename); + unlink(PATH_DATA ."sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP. $pro_uid. PATH_SEP .str_replace(".php","Post",$filename).".php"); + + $this->success = true; + $this->msg = G::LoadTranslation('ID_WEB_ENTRY_SUCCESS_DELETE'); + } + //Check Credentials + function checkCredentials($params){ + require_once 'classes/model/Event.php'; + require_once 'classes/model/Users.php'; + require_once 'classes/model/TaskUser.php'; + require_once 'classes/model/GroupUser.php'; + $sPRO_UID = $params->PRO_UID; + $sEVN_UID = $params->EVN_UID; + //$sDYNAFORM = $params->DYN_UID; + $sWS_USER = trim($params->WS_USER); + $sWS_PASS = trim($params->WS_PASS); + + if (G::is_https ()) + $http = 'https://'; + else + $http = 'http://'; + + $endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; + @$client = new SoapClient ( $endpoint ); + + $user = $sWS_USER; + $pass = $sWS_PASS; + + $parameters = array ('userid' => $user, 'password' => $pass ); + $result = $client->__SoapCall ( 'login', array ($parameters) ); + + $fields ['status_code'] = $result->status_code; + $fields ['message'] = 'ProcessMaker WebService version: ' . $result->version . "\n" . $result->message; + $fields ['version'] = $result->version; + $fields ['time_stamp'] = $result->timestamp; + $messageCode = true; + $message = $result->message; + + G::LoadClass ( 'Task' ); + //G::LoadClass ( 'Event' ); + G::LoadClass ( 'User' ); + G::LoadClass ( 'TaskUser' ); + G::LoadClass ( 'Groupwf' ); + + $event = new Event(); + $event->load($sEVN_UID); + $sTASKS = $event->getEvnTasUidTo(); + + $task = new Task(); + $task->load($sTASKS); + $sTASKS_SEL = $task->getTasTitle(); + + if(!class_exists('GroupUser')) { + G::LoadClass ( 'GroupUser' ); + } + // if the user has been authenticated, then check if has the rights or + // permissions to create the webentry + if ($result->status_code == 0) { + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(UsersPeer::USR_UID); + $oCriteria->addSelectColumn(TaskUserPeer::USR_UID); + $oCriteria->addSelectColumn(TaskUserPeer::TAS_UID); + $oCriteria->addJoin(TaskUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->add(TaskUserPeer::TAS_UID, $sTASKS); + $oCriteria->add(UsersPeer::USR_USERNAME, $sWS_USER); + //$oCriteria->add(TaskUserPeer::TU_RELATION,1); + $userIsAssigned = TaskUserPeer::doCount($oCriteria); + // if the user is not assigned directly, maybe a have the task a group with the user + if($userIsAssigned<1) { + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(UsersPeer::USR_UID); + $oCriteria->addJoin(UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->addJoin(GroupUserPeer::GRP_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->add(TaskUserPeer::TAS_UID, $sTASKS); + $oCriteria->add(UsersPeer::USR_USERNAME, $sWS_USER); + $userIsAssigned = GroupUserPeer::doCount($oCriteria); + if (!($userIsAssigned>=1)) { + $messageCode = false; + $message = "The User \"".$sWS_USER."\" doesn't have the task \"".$sTASKS_SEL."\" assigned."; + } + } + + } else { + $messageCode = false; + } + + $this->success = $messageCode; + $this->msg = $message; + } + //Save New WebEntry + function saveWebEntry($params){ + require_once 'classes/model/Event.php'; + global $G_FORM; + $sPRO_UID = $params->pro_uid; + $sEVN_UID = $params->evn_uid; + $sDYNAFORM = $params->initDyna; + $sWS_USER = trim($params->username); + $sWS_PASS = trim($params->password); + $sWS_ROUNDROBIN = ''; + $sWE_USR = ''; + $xDYNA = $params->dynaform; + + if ($xDYNA != ''){ + $pro_uid = $params->pro_uid; + $filename = $xDYNA; + $filename = $filename.'.php'; + unlink(PATH_DATA ."sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP. $pro_uid. PATH_SEP.$filename); + unlink(PATH_DATA ."sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP. $pro_uid. PATH_SEP .str_replace(".php","Post",$filename).".php"); + } + + //return $params; + + if (file_exists ( PATH_METHODS . 'login/version-pmos.php' )) { + include_once (PATH_METHODS . 'login/version-pmos.php'); + } else { + define ( 'PM_VERSION', 'Dev.' ); + } + + $pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP; + G::mk_dir ( $pathProcess, 0777 ); + + $oEvent = new Event(); + $oEvent->load($sEVN_UID); + $sTASKS = $oEvent->getEvnTasUidTo(); + + $oTask = new Task(); + $oTask->load($sTASKS); + $tas_title = $oTask->getTasTitle(); + + if (G::is_https ()) + $http = 'https://'; + else + $http = 'http://'; + + $sContent = ''; + $SITE_PUBLIC_PATH = ''; + if (file_exists ( $SITE_PUBLIC_PATH . '' )) {} + + require_once 'classes/model/Dynaform.php'; + $oDynaform = new Dynaform ( ); + $aDynaform = $oDynaform->load ( $sDYNAFORM ); + $dynTitle = str_replace ( ' ', '_', str_replace ( '/', '_', $aDynaform['DYN_TITLE'] ) ); + $sContent = "AddContent('dynaform', 'xmlform', '" . $sPRO_UID . '/' . $sDYNAFORM . "', '', array(), '" . $dynTitle . 'Post.php' . "');\n"; + $sContent .= "G::RenderPage('publish', 'blank');"; + file_put_contents ( $pathProcess . $dynTitle . '.php', $sContent ); + //creating the second file, the post file who receive the post form. + $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentryPost.tpl'; + $template = new TemplatePower ( $pluginTpl ); + $template->prepare (); + $template->assign ( 'wsdlUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2' ); + $template->assign ( 'wsUploadUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/upload' ); + $template->assign ( 'processUid', $sPRO_UID ); + $template->assign ( 'dynaformUid', $sDYNAFORM ); + $template->assign ( 'taskUid', $sTASKS ); + $template->assign ( 'wsUser', $sWS_USER ); + $template->assign ( 'wsPass', 'md5:' . md5 ( $sWS_PASS ) ); + $template->assign ( 'wsRoundRobin', $sWS_ROUNDROBIN ); + + if($sWE_USR == "2"){ + $template->assign ( 'USR_VAR', "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;" ); + } else { + $template->assign ( 'USR_VAR', '$USR_UID = -1;' ); + } + + $template->assign ( 'dynaform', $dynTitle ); + $template->assign ( 'timestamp', date ( 'l jS \of F Y h:i:s A' ) ); + $template->assign ( 'ws', SYS_SYS ); + $template->assign ( 'version', PM_VERSION ); + + $fileName = $pathProcess . $dynTitle . 'Post.php'; + file_put_contents ( $fileName, $template->getOutputContent () ); + //creating the third file, only if this wsClient.php file doesn't exists. + $fileName = $pathProcess . 'wsClient.php'; + $pluginTpl = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . 'ws' . PATH_SEP . 'wsClient.php'; + + if ( file_exists ($fileName) ) { + if( filesize($fileName) != filesize($pluginTpl) ){ + @copy($fileName, $pathProcess . 'wsClient.php.bck'); + @unlink($fileName); + + $template = new TemplatePower ( $pluginTpl ); + $template->prepare (); + file_put_contents ( $fileName, $template->getOutputContent () ); + } + } else { + $template = new TemplatePower ( $pluginTpl ); + $template->prepare (); + file_put_contents ( $fileName, $template->getOutputContent () ); + } + + require_once 'classes/model/Event.php'; + $oEvent = new Event ( ); + $aDataEvent = array(); + + $aDataEvent['EVN_UID'] = $sEVN_UID; + $aDataEvent['EVN_RELATED_TO'] = 'MULTIPLE'; + $aDataEvent['EVN_ACTION'] = $sDYNAFORM; + $aDataEvent['EVN_CONDITIONS'] = $sWS_USER; + $output = $oEvent->update($aDataEvent); + + $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; + + $this->success = true; + $this->msg = G::LoadTranslation('ID_WEB_ENTRY_SUCCESS_NEW'); + $this->W_LINK = $link; + $this->TAS_TITLE = $tas_title; + $this->DYN_TITLE = $dynTitle; + $this->USR_UID = $sWS_USER; + } +} //End webEntryProxy \ No newline at end of file diff --git a/workflow/engine/methods/processes/processes_webEntryGenerate.php b/workflow/engine/methods/processes/processes_webEntryGenerate.php index e8b67aa47..891358d60 100644 --- a/workflow/engine/methods/processes/processes_webEntryGenerate.php +++ b/workflow/engine/methods/processes/processes_webEntryGenerate.php @@ -23,6 +23,7 @@ try { $oTask = new Task ( ); $TaskFields = $oTask->load ( $sTASKS ); + $WE_EVN_UID = $oTask->getStartingEvent($sTASKS); if ($TaskFields['TAS_ASSIGN_TYPE'] != 'BALANCED') { throw (new Exception ( "The task '" . $TaskFields['TAS_TITLE'] . "' doesn't have a valid assignment type. The task needs to have a 'Cyclical Assignment'." )); } @@ -113,9 +114,10 @@ try { $oEvent = new Event ( ); $aDataEvent = array(); - $aDataEvent['EVN_UID'] = $oData->WE_EVN_UID; + $aDataEvent['EVN_UID'] = $WE_EVN_UID; //$oData->WE_EVN_UID; $aDataEvent['EVN_RELATED_TO'] = 'MULTIPLE'; $aDataEvent['EVN_ACTION'] = $sDYNAFORM; + $aDataEvent['EVN_CONDITIONS'] = $sWS_USER; $output = $oEvent->update($aDataEvent); //Show link $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; diff --git a/workflow/engine/templates/bpmn/pmosExt.js b/workflow/engine/templates/bpmn/pmosExt.js index ae697c773..c6f3a00da 100755 --- a/workflow/engine/templates/bpmn/pmosExt.js +++ b/workflow/engine/templates/bpmn/pmosExt.js @@ -48,291 +48,287 @@ pmosExt.prototype.addExtJsWindow = function(items,width,height,title) } pmosExt.prototype.popWebEntry= function(_5678) { - var oTask = workflow.taskUid; - var oDyna = workflow.dynaList; - var webForm = new Ext.FormPanel({ - labelWidth : 120, // label settings here cascade unless overridden - frame : true, - title : '', - bodyStyle : 'padding:5px 5px 0', - width : 500, - height : 400, - defaultType : 'textfield', - buttonAlign : 'center', - items: [ - { - xtype :'fieldset', - title : _('ID_WEBENTRY_LINK'), - collapsible: false, - autoHeight :true, - buttonAlign: 'center', - defaults : {width: 210}, - items: [ - { - xtype : 'displayfield', - fieldLabel : 'Link', - name : 'WEB_LINK' - },{ - xtype : 'fieldset', - layout :'column', - border :false, - align :'center', - items:[{ - columnWidth:.3, - layout: 'form', - border:false, - items : [{ - xtype : 'button', - id : 'edit', - text : _('ID_EDIT'), - bodyStyle: 'padding-left:35px;', - handler : function(){ - var properties = workflow.webForm.items.items[1]; - var credential = workflow.webForm.items.items[2]; - properties.show(); - credential.show(); - workflow.webEntrywindow.buttons[0].enable(); - workflow.webEntrywindow.setHeight(450); - } - }] - },{ - columnWidth:.3, - layout : 'form', - border : false, - items: [{ - xtype : 'button', - id : 'cancel', - text : _('ID_CANCEL'), - handler: function(){ - var properties = workflow.webForm.items.items[1]; - var credential = workflow.webForm.items.items[2]; - properties.hide(); - credential.hide(); - workflow.webEntrywindow.buttons[0].disable(); - workflow.webEntrywindow.setHeight(225); - } - }] - }] - } - ] - }, - { - xtype :'fieldset', - title : _('ID_PROPERTIES'), - collapsible : false, - autoHeight :true, - defaults : {width: 210}, - defaultType : 'textfield', - items: [{ - width : 200, - xtype : 'combo', - mode : 'local', - forceSelection : true, - allowBlank : false, - triggerAction : 'all', - fieldLabel : _('ID_INITIAL_TASK'), - name : 'initTask', - hiddenName : 'initTask', - displayField : 'name', - valueField : 'value', - store : new Ext.data.JsonStore({ - fields : ['name', 'value'], - data :oTask - }) - },{ - width : 200, - xtype : 'combo', - mode : 'local', - forceSelection : true, - allowBlank : false, - triggerAction : 'all', - fieldLabel : _('ID_INITIAL_DYNAFORM'), - name : 'initDyna', - hiddenName : 'initDyna', - displayField : 'name', - valueField : 'value', - store : new Ext.data.JsonStore({ - fields : ['name', 'value'], - data :oDyna - }) - },{ - width : 200, - xtype : 'combo', - mode : 'local', - forceSelection : true, - allowBlank : false, - triggerAction : 'all', - editable : false, - fieldLabel : _('ID_METHODS'), - name : 'methods', - hiddenName : 'methods', - displayField : 'name', - valueField : 'value', - scope : workflow, - store : new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'PHP Pages with Web Services', value: 'WS'}, - {name : 'Single HTML', value: 'SINGLE'}, - ] - }), - onSelect: function(record, index){ - var fields = workflow.webForm.items.items; - if(index == 1) { //Select - fields[2].collapse(); - workflow.webEntrywindow.buttons[0].disable(); - workflow.webEntrywindow.buttons[1].enable(); - } - else { - fields[2].expand(); - workflow.webEntrywindow.buttons[0].enable(); - workflow.webEntrywindow.buttons[1].disable(); - } - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }, { - width : 200, - xtype : 'combo', - mode : 'local', - forceSelection : true, - triggerAction : 'all', - editable : false, - allowBlank : false, - fieldLabel : _('ID_INPUT_DOC_ACCESS'), - name : 'inputDocAccess', - hiddenName : 'inputDocAccess', - displayField : 'name', - valueField : 'value', - store : new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'No Restriction', value: '1'}, - {name : 'Restricted to Process Permission', value: '2'}, - ] - }) - }] - },{ - xtype :'fieldset', - title : _('ID_PHP_WEB_SERVICE'), - collapsible : false, - autoHeight :true, - defaults : {width: 210}, - defaultType : 'textfield', - items: [{ - fieldLabel : _('ID_WEB_SERVICE_USER'), - name : 'webserviceUser', - allowBlank :true - },{ - fieldLabel : _('ID_WEB_SERVICE_PASSWORD'), - name : 'webservicePassword', - allowBlank :true, - inputType :'password' - }] - }] - }); + var oTask = workflow.taskUid; + var oDyna = workflow.dynaList; - webForm.render(document.body); - workflow.webForm = webForm; + var newButton = new Ext.Action({ + text: _('ID_NEW_WEB_ENTRY'), + iconCls: 'button_menu_ext ss_sprite ss_add', + hidden: true, + handler: function(){ + webForm.hide(); + //editForm.reset(); + editForm.getForm().findField('pro_uid').setValue(pro_uid); + editForm.getForm().findField('evn_uid').setValue(evn_uid); + editForm.getForm().findField('dynaform').setValue(''); + editForm.show(); + newButton.disable(); + } + }); - webEntrywindow = new Ext.Window({ - title : _('ID_START_MESSAGE_EVENT_WEB_ENTRY'), - collapsible : false, - maximizable : false, - width : 450, - height : 375, - minWidth : 300, - minHeight : 200, - layout : 'fit', - plain : true, - bodyStyle : 'padding:5px;', - buttonAlign : 'center', - items : webForm, - scope : workflow, - buttons : [{ - text: _('ID_TEST_CONFIGURATION'), - handler: function(){ - var propertiesfields = workflow.webForm.items.items[1].items.items; - var credentialFields = workflow.webForm.items.items[2].items.items; - var task_uid = propertiesfields[0].getValue(); - var dyna_uid = propertiesfields[1].getValue(); - var we_type = propertiesfields[2].getValue(); - var we_usr = propertiesfields[3].getValue(); - var tasName = 'test'; - var username = credentialFields[0].getValue(); - var password = credentialFields[1].getValue(); - var args = '?action=webEntry_validate&data={"PRO_UID":"'+pro_uid +'", "TASKS":"'+task_uid+'", "DYNAFORM":"'+dyna_uid+'", "WE_TYPE":"'+we_type+'", "WS_USER":"'+username+'", "WS_PASS":"'+password+'", "WS_ROUNDROBIN":"", "WE_USR":"'+we_usr+'", "TASKS_NAME":"'+tasName+'"}'; - Ext.Ajax.request({ - url: 'processes_Ajax.php'+ args, - success: function(response) { - if(response.responseText == "1") - workflow.webEntrywindow.buttons[1].enable(); - else - { - Ext.Msg.alert (response.responseText); - workflow.webEntrywindow.buttons[1].disable(); - } - }, - failure: function(){ - PMExt.notify( _('ID_STATUS') , _('ID_FAILURE') ); - } - }); - } - },{ - text: _('ID_GENERATE_WEB_ENTRY_PAGE'), - disabled:true, - handler: function(){ - var webEntryLink = workflow.webForm.items.items[0].items.items; - var propertiesfields = workflow.webForm.items.items[1].items.items; - var credentialFields = workflow.webForm.items.items[2].items.items; - var evn_uid = workflow.currentSelection.id; - var task_uid = propertiesfields[0].getValue(); - var dyna_uid = propertiesfields[1].getValue(); - var we_type = propertiesfields[2].getValue(); - var we_usr = propertiesfields[3].getValue(); - var username = credentialFields[0].getValue(); - var password = credentialFields[1].getValue(); - var args = '?action=webEntry_generate&data={"PRO_UID":"'+pro_uid +'", "TASKS":"'+task_uid+'", "DYNAFORM":"'+dyna_uid+'", "WE_TYPE":"'+we_type+'", "WS_USER":"'+username+'", "WS_PASS":"'+password+'", "WS_ROUNDROBIN":"", "WE_USR":"'+we_usr+'", "WE_EVN_UID":"'+evn_uid+'"}'; - Ext.Ajax.request({ - url: 'processes_Ajax.php'+ args, - success: function(response) { - webEntryLink = response.responseText; - webForm.getForm().findField('WEB_LINK').setValue("" + webEntryLink + "<\/a>"); - // webEntryLink[0].setValue(response.responseText); - workflow.webForm.items.items[0].show(); - workflow.webForm.items.items[1].hide(); - workflow.webForm.items.items[2].hide(); - workflow.webEntrywindow.buttons[1].disable(); - }, - failure: function(){ - PMExt.notify( _('ID_STATUS') , _('ID_FAILURE') ); - } - }); - } - }] - }); - workflow.webEntrywindow = webEntrywindow; - webEntrywindow.show(); + var editButton = new Ext.Action({ + text: _('ID_EDIT'), + iconCls: 'button_menu_ext ss_sprite ss_pencil', + hidden: true, + handler: function(){ + webForm.hide(); + //editForm.reset(); + editForm.title = _('ID_EDIT_WEB_ENTRY'); + editForm.getForm().findField('pro_uid').setValue(pro_uid); + editForm.getForm().findField('evn_uid').setValue(evn_uid); + editForm.getForm().findField('dynaform').setValue(webEntryList.data[0].DYN_TITLE); + editForm.getForm().findField('username').setValue(webEntryList.data[0].USR_UID); + editForm.getForm().findField('initDyna').setValue(webEntryList.data[0].DYN_UID); + editForm.show(); + editButton.disable(); + deleteButton.disable(); + } + }); - var evn_uid = workflow.currentSelection.id; - var urlparams = '?action=webEntry&data={"uid":"'+ pro_uid +'","evn_uid":"'+evn_uid+'"}'; - webForm.form.load({ - url: "processes_Ajax.php"+ urlparams, - method:'GET', - waitMsg:'Loading', - success:function(form, action) { - webEntryList = Ext.util.JSON.decode(action.response.responseText); - form.findField('WEB_LINK').setValue("" + webEntryList.data[0].W_LINK + "<\/a>"); - var propertiesfields = form.items.items[1]; - var credentialFields = form.items.items[2]; - webEntrywindow.setHeight(210); - webEntrywindow.show(); + var deleteButton = new Ext.Action({ + text: _('ID_DELETE'), + iconCls: 'button_menu_ext ss_sprite ss_delete', + hidden: true, + handler: function(){ + Ext.Msg.confirm(_('ID_CONFIRM'),_('ID_CONFIRM_DELETE_WEB_ENTRY'), function(btn, text){ + if (btn=='yes'){ + var file_name = webForm.getForm().findField('dynaform').getValue(); + Ext.Ajax.request({ + url: '../webEntryProxy/deleteWebEntry', + params: {PRO_UID: pro_uid, EVN_UID: evn_uid, FILE_NAME: file_name}, + success: function (r,o){ + response = Ext.util.JSON.decode(r.responseText); + if (response.success){ + PMExt.notify(_('ID_WEB_ENTRY'),response.msg); + newButton.show(); + editButton.hide(); + deleteButton.hide(); + webForm.getForm().findField('link').setValue(_('ID_NOT_DEFINED')); + webForm.getForm().findField('task').setValue(_('ID_NOT_DEFINED'); + webForm.getForm().findField('dynaform').setValue(_('ID_NOT_DEFINED'); + webForm.getForm().findField('user').setValue(_('ID_NOT_DEFINED'); + goToWebEntry.disable(); + webForm.show(); + editForm.hide(); + }else{ + PMExt.error(_('ID_ERROR'),response.msg); + } + }, + failure: function (r,o){ + PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); + } + }); + } + }); + } + }); + + var goToWebEntry = new Ext.Action({ + text: _('ID_TEST_WEB_ENTRY'), + disabled: true, + handler: function(){ + var url = webForm.getForm().findField('link').getValue(); + window.open(url,'',''); + } + }); + + var saveButton = new Ext.Action({ + text: _('ID_SAVE'), + disabled: false, + handler: function(){ + var user = editForm.getForm().findField('username').getValue(); + var pass = editForm.getForm().findField('password').getValue(); + + Ext.Ajax.request({ + url: '../webEntryProxy/checkCredentials', + params: {PRO_UID: pro_uid, EVN_UID: evn_uid, WS_USER: user, WS_PASS: pass}, + success: function(r,o){ + var resp = Ext.util.JSON.decode(r.responseText); + if (resp.success){ + editForm.getForm().submit({ + success: function(f,a){ + var rs = Ext.util.JSON.decode(a.response.responseText); + if (rs.success){ + newButton.hide(); + editButton.show(); + deleteButton.show(); + webForm.getForm().findField('link').setValue(rs.W_LINK); + webForm.getForm().findField('task').setValue(rs.TAS_TITLE); + webForm.getForm().findField('dynaform').setValue(rs.DYN_TITLE); + webForm.getForm().findField('user').setValue(rs.USR_UID); + goToWebEntry.enable(); + webForm.show(); + editForm.hide(); + newButton.enable(); + editButton.enable(); + deleteButton.enable(); + PMExt.notify(_('ID_WEB_ENTRY'),rs.msg); + }else{ + PMExt.error(_('ID_WEB_ENTRY'),rs.msg); + } }, - failure:function(form, action) { + failure: function(f,r){ PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); } }); + }else{ + PMExt.error(_('ID_CREDENTIAL_ERROR'),resp.msg); + } + }, + failure: function(r,o){ + PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); + } + }); + } + }); + + var cancelButton = new Ext.Action({ + text: _('ID_CANCEL'), + disabled: false, + handler: function(){ + editForm.hide(); + webForm.show(); + newButton.enable(); + editButton.enable(); + deleteButton.enable(); + } + }); + var webEntryList; + + + var webForm = new Ext.FormPanel({ + labelWidth : 120, // label settings here cascade unless overridden + frame : true, + width : 585, + autoHeight : true, + defaultType : 'textfield', + buttonAlign : 'center', + items: [ + { + xtype :'fieldset', + title : _('ID_WEB_ENTRY_SUMMARY'), + collapsible: false, + autoHeight :true, + buttonAlign: 'center', + defaults : {width: 210}, + items: [ + {xtype: 'textfield', fieldLabel: _('ID_WEB_ENTRY_LINK'), name: 'link', width: 400, readOnly: true, selectOnFocus: true}, + {xtype: 'textfield', fieldLabel: _('ID_TASK'), name: 'task', width: 400, readOnly: true}, + {xtype: 'textfield', fieldLabel: _('ID_INITIAL_DYNAFORM'), name: 'dynaform', width: 400, readOnly: true}, + {xtype: 'textfield', fieldLabel: _('ID_USER'), name: 'user', width: 400, readOnly: true} + ] + } + ], + buttons: [goToWebEntry] + , hidden: true + }); + + var editForm = new Ext.FormPanel({ + labelWidth : 120, // label settings here cascade unless overridden + frame : true, + width : 585, + autoHeight : true, + defaultType : 'textfield', + buttonAlign : 'center', + url : '../webEntryProxy/saveWebEntry', + items: [ + {xtype: 'hidden', name: 'pro_uid', hidden: true}, + {xtype: 'hidden', name: 'evn_uid', hidden: true}, + {xtype: 'hidden', name: 'dynaform', hidden: true}, + { + xtype :'fieldset', + title : _('ID_NEW_WEB_ENTRY'), + collapsible: false, + autoHeight :true, + buttonAlign: 'center', + defaults : {width: 210}, + items: [ + { + width : 400, + xtype : 'combo', + mode : 'local', + forceSelection : true, + allowBlank : false, + triggerAction : 'all', + fieldLabel : _('ID_INITIAL_DYNAFORM'), + name : 'initDyna', + hiddenName : 'initDyna', + displayField : 'name', + valueField : 'value', + store : new Ext.data.JsonStore({ + fields : ['name', 'value'], + data :oDyna + }) + }, + {xtype: 'textfield', fieldLabel: _('ID_USER'), name: 'username', width: 200, allowBlank: false}, + {xtype: 'textfield', fieldLabel: _('ID_PASSWORD'), name: 'password', width: 200, inputType: 'password', allowBlank: false} + ] + } + ], + hidden: true, + buttons: [saveButton, cancelButton] + }); + + + var webEntryWindow = new Ext.Window({ + title:_('ID_START_MESSAGE_EVENT_WEB_ENTRY'), + //autoScroll: true, + collapsible: false, + //maximizable: true, + width: 600, + //bodyStyle : 'padding:8px 0 0 8px;', + //autoHeight: true, + autoHeight: true, + layout: 'fit', + plain: true, + buttonAlign: 'center', + scope : workflow, + modal: true, + items: [webForm, editForm], + tbar: [newButton, editButton, deleteButton] + }); + workflow.webEntryWindow = webEntryWindow; + + + var evn_uid = workflow.currentSelection.id; + Ext.Ajax.request({ + url: 'processes_Ajax.php', + params:{action:'webEntry', data: '{"uid":"'+ pro_uid +'","evn_uid":"'+evn_uid+'"}'}, + success: function(r,o){ + webEntryList = Ext.util.JSON.decode(r.responseText); + if (webEntryList.success){ + if (webEntryList.data[0].W_LINK !=''){ + newButton.hide(); + editButton.show(); + deleteButton.show(); + webForm.getForm().findField('link').setValue(webEntryList.data[0].W_LINK); + webForm.getForm().findField('task').setValue(webEntryList.data[0].TAS_TITLE); + webForm.getForm().findField('dynaform').setValue(webEntryList.data[0].DYN_TITLE); + webForm.getForm().findField('user').setValue(webEntryList.data[0].USR_UID); + goToWebEntry.enable(); + webForm.show(); + }else{ + newButton.show(); + editButton.hide(); + deleteButton.hide(); + webForm.getForm().findField('link').setValue(_('ID_NOT_DEFINED'); + webForm.getForm().findField('task').setValue(_('ID_NOT_DEFINED'); + webForm.getForm().findField('dynaform').setValue(_('ID_NOT_DEFINED'); + webForm.getForm().findField('user').setValue(_('ID_NOT_DEFINED'); + goToWebEntry.disable(); + webForm.show(); + } + }else{ + PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); + } + }, + failure: function(r,o){ + PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); + } + }); + + webEntryWindow.show(); } pmosExt.prototype.popCaseSchedular= function(_5678){ Ext.QuickTips.init();