diff --git a/gulliver/js/pmchart/pmCharts.js b/gulliver/js/pmchart/pmCharts.js index e0be418c8..11b446e1b 100644 --- a/gulliver/js/pmchart/pmCharts.js +++ b/gulliver/js/pmchart/pmCharts.js @@ -115,7 +115,7 @@ BarChart.prototype.drawBars = function(data, canvas, param) { .attr("x", graphDim.left*2 + graphDim.width/2) .attr("dy", "1.5em") .style("text-anchor", "end") - .text("No data to draw..."); + .text(param.canvas.noDataText); data = [ {"value":"0", "datalabel":"None"} ]; } @@ -1097,7 +1097,7 @@ PieChart.prototype.drawChart = function () { PieChart.prototype.drawPie2D = function (dataset, canvas, param) { if (dataset == null || dataset.length == 0) { - this.$container.html( "
No data to draw ...
" ); + this.$container.html( "
"+param.canvas.noDataText+"
" ); } var parameter = createDefaultParamsForGraphPie(param); @@ -1443,7 +1443,7 @@ Pie3DChart.prototype.drawChart = function () { Pie3DChart.prototype.drawPie3D = function (data, canvas, param) { if (data == null || data.length == 0) { - this.$container.html( "
No data to draw ...
" ); + this.$container.html( "
"+param.canvas.noDataText+"
" ); } var duration_transition = 0; @@ -1613,7 +1613,7 @@ RingChart.prototype.drawChart = function () { RingChart.prototype.drawRing = function(data, canvas, param){ if (data == null || data.length == 0) { - this.$container.html( "
No data to draw ...
" ); + this.$container.html( "
"+param.canvas.noDataText+"
" ); } //d3.select('#'+parent).select('svg').remove(); diff --git a/workflow/engine/classes/class.indicatorsCalculator.php b/workflow/engine/classes/class.indicatorsCalculator.php index badf19261..aeb6cc16f 100644 --- a/workflow/engine/classes/class.indicatorsCalculator.php +++ b/workflow/engine/classes/class.indicatorsCalculator.php @@ -513,9 +513,9 @@ class indicatorsCalculator $params[':usrUid'] = $usrUid; $sqlString = "SELECT - COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS OVERDUE, - COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) > 0 ) , 0 ) AS ONTIME, - COALESCE( SUM( DATEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 ) , 0 ) AS ATRISK + COALESCE( SUM( TIMEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS OVERDUE, + COALESCE( SUM( TIMEDIFF( DEL_RISK_DATE , NOW( ) ) > 0 ) , 0 ) AS ONTIME, + COALESCE( SUM( TIMEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 && TIMEDIFF( DEL_DUE_DATE , NOW( ) ) > 0) , 0 ) AS ATRISK FROM LIST_INBOX WHERE USR_UID = :usrUid AND APP_STATUS = 'TO_DO' @@ -534,9 +534,9 @@ class indicatorsCalculator APP_TAS_TITLE AS taskTitle, APP_PRO_TITLE AS proTitle, - COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS overdue, - COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) > 0 ) , 0 ) AS onTime, - COALESCE( SUM( DATEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 ) , 0 ) AS atRisk + COALESCE( SUM( TIMEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS overdue, + COALESCE( SUM( TIMEDIFF( DEL_RISK_DATE , NOW( ) ) > 0 ) , 0 ) AS onTime, + COALESCE( SUM( TIMEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 && TIMEDIFF( DEL_DUE_DATE , NOW( ) ) > 0) , 0 ) AS atRisk FROM LIST_INBOX WHERE USR_UID = :usrUid AND APP_STATUS = 'TO_DO' @@ -561,8 +561,8 @@ class indicatorsCalculator if (is_array($result) && isset($result[0])) { $response['overdue'] = $result[0]['OVERDUE']; - $response['atRisk'] = $result[0]['ONTIME']; - $response['onTime'] = $result[0]['ATRISK']; + $response['atRisk'] = $result[0]['ATRISK']; + $response['onTime'] = $result[0]['ONTIME']; $total = $response['overdue'] + $response['atRisk'] + $response['onTime']; if ($total != 0) { @@ -578,20 +578,20 @@ class indicatorsCalculator $result[$key]['overdue'] = $value['overdue']; $result[$key]['atRisk'] = $value['atRisk']; $result[$key]['onTime'] = $value['onTime']; - $result[$key]['percentageOverdue'] = 0; - $result[$key]['percentageAtRisk'] = 0; - $result[$key]['percentageOnTime'] = 0; - $result[$key]['percentageTotalOverdue'] = 0; - $result[$key]['percentageTotalAtRisk'] = 0; - $result[$key]['percentageTotalOnTime'] = 0; + $result[$key]['percentageOverdue'] = 0; + $result[$key]['percentageAtRisk'] = 0; + $result[$key]['percentageOnTime'] = 0; + $result[$key]['percentageTotalOverdue'] = 0; + $result[$key]['percentageTotalAtRisk'] = 0; + $result[$key]['percentageTotalOnTime'] = 0; $total = $value['overdue'] + $value['onTime'] + $value['atRisk']; if ($total != 0) { $result[$key]['percentageOverdue'] = ($value['overdue']*100)/$total; $result[$key]['percentageAtRisk'] = ($value['atRisk']*100)/$total; $result[$key]['percentageOnTime'] = ($value['onTime']*100)/$total; - $result[$key]['percentageTotalOverdue'] = $response['overdue'] != 0 ? ($value['overdue']*100)/$response['overdue']: 0; - $result[$key]['percentageTotalAtRisk'] = $response['atRisk'] != 0 ? ($value['atRisk']*100)/$response['atRisk'] : 0; - $result[$key]['percentageTotalOnTime'] = $response['onTime'] != 0 ? ($value['onTime']*100)/$response['onTime']: 0; + $result[$key]['percentageTotalOverdue'] = $response['overdue'] != 0 ? ($value['overdue']*100)/$response['overdue']: 0; + $result[$key]['percentageTotalAtRisk'] = $response['atRisk'] != 0 ? ($value['atRisk']*100)/$response['atRisk'] : 0; + $result[$key]['percentageTotalOnTime'] = $response['onTime'] != 0 ? ($value['onTime']*100)/$response['onTime']: 0; } } $response['dataList'] = $result; diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php index 91b444eef..724088f89 100755 --- a/workflow/engine/classes/model/AppDelegation.php +++ b/workflow/engine/classes/model/AppDelegation.php @@ -404,7 +404,7 @@ class AppDelegation extends BaseAppDelegation } //Risk date - $riskDate = $calendar->dashCalculateDate($this->getDelDelegateDate(), round($riskTime), $data['TAS_TIMEUNIT'], $arrayCalendarData); + $riskDate = $calendar->dashCalculateDate($this->getDelDelegateDate(), $riskTime, $data['TAS_TIMEUNIT'], $arrayCalendarData); return $riskDate; } catch (Exception $e) { diff --git a/workflow/engine/classes/model/DashboardIndicator.php b/workflow/engine/classes/model/DashboardIndicator.php index e0eef6b5c..baa10cc79 100644 --- a/workflow/engine/classes/model/DashboardIndicator.php +++ b/workflow/engine/classes/model/DashboardIndicator.php @@ -65,14 +65,18 @@ class DashboardIndicator extends BaseDashboardIndicator $oldValue = current(reset($calculator->peiHistoric($uid, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE))); $row['DAS_IND_VARIATION'] = $value - $oldValue; $row['DAS_IND_OLD_VALUE'] = $oldValue; - $row['DAS_IND_PERCENT_VARIATION'] = round(($value - $oldValue) * 100 / (($oldValue == 0) ? 1 : $oldValue), 1); + $row['DAS_IND_PERCENT_VARIATION'] = $oldValue != 0 + ? round(($value - $oldValue) * 100 / $oldValue) + : "--"; break; case '1030': $value = current(reset($calculator->ueiHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE))); $oldValue = current(reset($calculator->ueiHistoric($uid, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE))); $row['DAS_IND_VARIATION'] = $value - $oldValue; $row['DAS_IND_OLD_VALUE'] = $oldValue; - $row['DAS_IND_PERCENT_VARIATION'] = round(($value - $oldValue) * 100 / (($oldValue == 0) ? 1 : $oldValue), 1); + $row['DAS_IND_PERCENT_VARIATION'] = $oldValue != 0 + ? round(($value - $oldValue) * 100 / $oldValue) + : "--"; break; case '1050': $value = $calculator->statusIndicatorGeneral($userUid); diff --git a/workflow/engine/js/strategicDashboard/viewDashboardModel.js b/workflow/engine/js/strategicDashboard/viewDashboardModel.js index c2b63eca1..6a96e1c3f 100644 --- a/workflow/engine/js/strategicDashboard/viewDashboardModel.js +++ b/workflow/engine/js/strategicDashboard/viewDashboardModel.js @@ -78,7 +78,6 @@ ViewDashboardModel.prototype.getPositionIndicator = function(callBack) { "y" : originalObject.y, "width" : originalObject.width, "height" : originalObject.height - }; graphData.push(map); }); diff --git a/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js b/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js index 1890c651e..e1ed03b45 100644 --- a/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js +++ b/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js @@ -90,18 +90,37 @@ ViewDashboardPresenter.prototype.dashboardIndicatorsViewModel = function(data) { newObject.comparative = Math.round(newObject.comparative*1000)/1000; newObject.comparative = ((newObject.comparative > 0)? "+": "") + newObject.comparative; + newObject.percentComparative = (newObject.percentComparative != '--') + ? '(' + newObject.percentComparative + '%)' + : ""; + + newObject.value = (newObject.category == "normal") ? Math.round(newObject.value) + "" : Math.round(newObject.value*100)/100 + "" newObject.favorite = 0; - newObject.percentageOverdue = Math.round(newObject.percentageOverdue); - newObject.percentageAtRisk = Math.round(newObject.percentageAtRisk); - //to be sure that percentages sum up to 100 (the rounding will lost decimals)% - newObject.percentageOnTime = 100 - newObject.percentageOverdue - newObject.percentageAtRisk; - newObject.overdueVisibility = (newObject.percentageOverdue > 0)? "visible" : "hidden"; - newObject.atRiskVisibility = (newObject.percentageAtRisk > 0)? "visible" : "hidden"; - newObject.onTimeVisibility = (newObject.percentageOnTime > 0)? "visible" : "hidden"; + + newObject.percentageOverdueWidth = Math.round(newObject.percentageOverdue); + newObject.percentageAtRiskWidth = Math.round(newObject.percentageAtRisk); + //to be sure that percentages sum up to 100 (the rounding will lose decimals)% + newObject.percentageOnTimeWidth = 100 - newObject.percentageOverdueWidth - newObject.percentageAtRiskWidth; + + newObject.percentageOverdueToShow = ((newObject.percentageOverdue == 0 ||newObject.percentageOverdue == null ) + ? "" + : newObject.percentageOverdueWidth + "%"); + + newObject.percentageAtRiskToShow = ((newObject.percentageAtRisk == 0 || newObject.percentageAtRisk == null) + ? "" + : newObject.percentageAtRiskWidth + "%"); + + newObject.percentageOnTimeToShow = ((newObject.percentageOnTime == 0 || newObject.percentageOnTime == 0) + ? G_STRING['ID_INBOX'] + ' ' + G_STRING['ID_EMPTY'] + : newObject.percentageOnTimeWidth + "%"); + + newObject.overdueVisibility = (newObject.percentageOverdueWidth > 0) ? "visible" : "hidden"; + newObject.atRiskVisibility = (newObject.percentageAtRiskWidth > 0) ? "visible" : "hidden"; + newObject.onTimeVisibility = (newObject.percentageOnTimeWidth > 0) ? "visible" : "hidden"; returnList.push(newObject); i++; }); diff --git a/workflow/engine/js/strategicDashboard/viewDashboardView.js b/workflow/engine/js/strategicDashboard/viewDashboardView.js index d62c6fc20..e56fb4f56 100644 --- a/workflow/engine/js/strategicDashboard/viewDashboardView.js +++ b/workflow/engine/js/strategicDashboard/viewDashboardView.js @@ -353,20 +353,17 @@ $(document).ready(function() { presenter.getDashboardIndicators(dashboardId, defaultInitDate(), defaultEndDate()) .done(function(indicatorsVM) { fillIndicatorWidgets(indicatorsVM); - //TODO use real data loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate()); }); }); $('#indicatorsGridStack').on('click','.ind-button-selector', function() { var indicatorId = $(this).data('indicator-id'); - //TODO use real data loadIndicator(indicatorId, defaultInitDate(), defaultEndDate()); }); $('body').on('click','.bread-back-selector', function() { var indicatorId = window.currentIndicator.id; - //TODO use real data loadIndicator(indicatorId, defaultInitDate(), defaultEndDate()); return false; }); @@ -380,7 +377,6 @@ $(document).ready(function() { "inefficiencyCost":$(this).data('detail-cost'), "name":$(this).data('detail-name') }; - //TODO PASS REAL VALUES presenter.getSpecialIndicatorSecondLevel(detailId, window.currentIndicator.type, defaultInitDate(), defaultEndDate()) .done(function (viewModel) { fillSpecialIndicatorSecondView(viewModel); @@ -406,8 +402,15 @@ var hideTitleAndSortDiv = function(){ switch (window.currentIndicator.type) { case "1010": case "1030": - $('#relatedLabel').css('visibility', 'visible'); - $('#relatedLabel').show(); + if($('.detail-button-selector').length == 0) { + $('#relatedLabel').hide(); + //$('#relatedLabel').find('h3').text(G_STRING['ID_NO_DATA_TO_DISPLAY']); + } + else { + $('#relatedLabel').css('visibility', 'visible'); + $('#relatedLabel').show(); + } + break; default: $('#relatedLabel').hide(); @@ -419,7 +422,17 @@ var selectedOrderOfDetailList = function () { return ($('#sortListButton').hasClass('fa-chevron-up') ? "up" : "down"); } +var selectDefaultMonthAndYear = function () { + var compareDate = new Date(); + compareDate.setMonth(compareDate.getMonth() - 1); + var compareMonth = compareDate.getMonth() + 1; + var compareYear = compareDate.getYear(); + $('#month').val(compareMonth); + $('#year').val(compareYear); +} + var initialDraw = function () { + selectDefaultMonthAndYear(); presenter.getUserDashboards(pageUserId) .then(function(dashboardsVM) { fillDashboardsList(dashboardsVM); @@ -523,10 +536,6 @@ var fillIndicatorWidgets = function (presenterData) { $.each(presenterData, function(key, indicator) { var $widget = widgetBuilder.getIndicatorWidget(indicator); grid.add_widget($widget, indicator.toDrawX, indicator.toDrawY, indicator.toDrawWidth, indicator.toDrawHeight, true); - //TODO will exist animation? - /*if (indicator.category == "normal") { - animateProgress(indicator, $widget); - }*/ var $title = $widget.find('.ind-title-selector'); if (indicator.favorite == "1") { $title.addClass("panel-active"); @@ -548,7 +557,8 @@ var fillStatusIndicatorFirstView = function (presenterData) { containerId:'graph1', width:300, height:300, - stretch:true + stretch:true, + noDataText: G_STRING.ID_DISPLAY_EMPTY }, graph: { @@ -608,7 +618,8 @@ var fillSpecialIndicatorFirstView = function(presenterData) { containerId:'specialIndicatorGraph', width:300, height:300, - stretch:true + stretch:true, + noDataText: G_STRING.ID_NO_INEFFICIENT_PROCESSES }, graph: { allowDrillDown:false, @@ -627,7 +638,8 @@ var fillSpecialIndicatorFirstView = function(presenterData) { containerId:'specialIndicatorGraph', width:500, height:300, - stretch:true + stretch:true, + noDataText: G_STRING.ID_NO_INEFFICIENT_USER_GROUPS }, graph: { allowDrillDown:false, @@ -725,11 +737,13 @@ var fillSpecialIndicatorSecondView = function(presenterData) { if (window.currentIndicator.type == "1010") { detailParams.graph.axisX.label = G_STRING['ID_TASK'] ; + detailParams.canvas.noDataText = G_STRING['ID_NO_INEFFICIENT_TASKS'] ; var graph = new BarChart(presenterData.dataToDraw, detailParams, null, null); graph.drawChart(); } if (window.currentIndicator.type == "1030") { + detailParams.canvas.noDataText = G_STRING['ID_NO_INEFFICIENT_USERS'] ; var graph = new BarChart(presenterData.dataToDraw, detailParams, null, null); graph.drawChart(); } diff --git a/workflow/engine/methods/cases/casesStreamingFile.php b/workflow/engine/methods/cases/casesStreamingFile.php index 66dc2bc17..77116077d 100644 --- a/workflow/engine/methods/cases/casesStreamingFile.php +++ b/workflow/engine/methods/cases/casesStreamingFile.php @@ -50,6 +50,22 @@ if ($actionAjax == "streaming") { exit(0); } +if ($actionAjax == "fileMobile") { + $app_uid = isset( $_REQUEST['a'] ) ? $_REQUEST['a'] : null; + $inp_doc_uid = isset( $_REQUEST['d'] ) ? $_REQUEST['d'] : null; + + $structure = file_get_contents(PATH_HTML ."/mobile/index.json"); + $structure = json_decode($structure); + foreach($structure as $build){ + foreach($build as $file){ + $file->lastModified = date ("D, d M Y H:i:s \G\M\T", filemtime(PATH_HTML ."/mobile/".$file->file)); + } + } + G::header( 'Content-Type: application/json' ); + echo G::json_encode($structure); + exit(0); +} + exit; function rangeDownload($location,$mimeType) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Light.php b/workflow/engine/src/ProcessMaker/BusinessModel/Light.php index 97d42f082..98c92052b 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Light.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Light.php @@ -54,7 +54,7 @@ class Light $task = new \ProcessMaker\BusinessModel\Task(); $task->setFormatFieldNameInUppercase(false); $task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid")); - + $step = new \ProcessMaker\Services\Api\Project\Activity\Step(); $response = array(); foreach ($processList as $key => $processInfo) { $tempTreeChildren = array (); @@ -71,6 +71,9 @@ class Light $newForm[$c]['index'] = $c+1; $newForm[$c]['title'] = $form['obj_title']; $newForm[$c]['description'] = $form['obj_description']; + $newForm[$c]['stepId'] = $form["step_uid"]; + $trigger = $this->statusTriggers($step->doGetActivityStepTriggers($form["step_uid"], $tempTreeChild['taskId'], $tempTreeChild['processId'])); + $newForm[$c]["triggers"] = $trigger; $c++; } } @@ -87,6 +90,20 @@ class Light return $response; } + public function statusTriggers($triggers) + { + $return = array("before" => false, "after"=> false); + foreach($triggers as $trigger){ + if ($trigger['st_type'] == "BEFORE"){ + $return["before"]= true; + } + if ($trigger['st_type'] == "AFTER"){ + $return["after"]= true; + } + } + return $return; + } + /** * Get counters each type of list * @param $userId @@ -810,5 +827,229 @@ class Light } return $response; } + + /** + * GET return array category + * + * @return array + */ + public function getCategoryList () + { + $category = array (); + $category[] = array ("", G::LoadTranslation( "ID_ALL_CATEGORIES" )); + + $criteria = new Criteria( 'workflow' ); + $criteria->addSelectColumn( \ProcessCategoryPeer::CATEGORY_UID ); + $criteria->addSelectColumn( \ProcessCategoryPeer::CATEGORY_NAME ); + $criteria->addAscendingOrderByColumn(\ProcessCategoryPeer::CATEGORY_NAME); + + $dataset = \ProcessCategoryPeer::doSelectRS( $criteria ); + $dataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); + $dataset->next(); + + while ($row = $dataset->getRow()) { + $category[] = array ($row['CATEGORY_UID'],$row['CATEGORY_NAME']); + $dataset->next(); + } + return $category; + } + + /** + * @param $action + * @param $categoryUid + * @param $userUid + * @return array + * @throws \PropelException + */ + public function getProcessList ($action, $categoryUid, $userUid) + { + //$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : null; + //$categoryUid = isset( $_REQUEST['CATEGORY_UID'] ) ? $_REQUEST['CATEGORY_UID'] : null; + //$userUid = (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null; + + // global $oAppCache; + $oAppCache = new \AppCacheView(); + $processes = array (); + $processes[] = array ('',G::LoadTranslation( 'ID_ALL_PROCESS' )); + + //get the list based in the action provided + switch ($action) { + case 'draft': + $cProcess = $oAppCache->getDraftListCriteria( $userUid ); //fast enough + break; + case 'sent': + $cProcess = $oAppCache->getSentListProcessCriteria( $userUid ); // fast enough + break; + case 'simple_search': + case 'search': + //in search action, the query to obtain all process is too slow, so we need to query directly to + //process and content tables, and for that reason we need the current language in AppCacheView. + G::loadClass( 'configuration' ); + $oConf = new \Configurations(); + $oConf->loadConfig( $x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '' ); + $appCacheViewEngine = $oConf->aConfig; + $lang = isset( $appCacheViewEngine['LANG'] ) ? $appCacheViewEngine['LANG'] : 'en'; + + $cProcess = new Criteria( 'workflow' ); + $cProcess->clearSelectColumns(); + $cProcess->addSelectColumn( \ProcessPeer::PRO_UID ); + $cProcess->addSelectColumn( \ContentPeer::CON_VALUE ); + if ($categoryUid) { + $cProcess->add( \ProcessPeer::PRO_CATEGORY, $categoryUid ); + } + $del = DBAdapter::getStringDelimiter(); + $conds = array (); + $conds[] = array (ProcessPeer::PRO_UID,ContentPeer::CON_ID); + $conds[] = array (ContentPeer::CON_CATEGORY,$del . 'PRO_TITLE' . $del); + $conds[] = array (ContentPeer::CON_LANG,$del . $lang . $del); + $cProcess->addJoinMC( $conds, Criteria::LEFT_JOIN ); + $cProcess->add( ProcessPeer::PRO_STATUS, 'ACTIVE' ); + $cProcess->addAscendingOrderByColumn(ContentPeer::CON_VALUE); + + $oDataset = ProcessPeer::doSelectRS( $cProcess ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + + while ($aRow = $oDataset->getRow()) { + $processes[] = array ($aRow['PRO_UID'],$aRow['CON_VALUE'] + ); + $oDataset->next(); + } + return print G::json_encode( $processes ); + break; + case 'unassigned': + $cProcess = $oAppCache->getUnassignedListCriteria( $userUid ); + break; + case 'paused': + $cProcess = $oAppCache->getPausedListCriteria( $userUid ); + break; + case 'to_revise': + $cProcess = $oAppCache->getToReviseListCriteria( $userUid ); + break; + case 'to_reassign': + $cProcess = $oAppCache->getToReassignListCriteria($userUid); + break; + case 'gral': + $cProcess = $oAppCache->getGeneralListCriteria(); + break; + case 'todo': + default: + $cProcess = $oAppCache->getToDoListCriteria( $userUid ); //fast enough + break; + } + //get the processes for this user in this action + $cProcess->clearSelectColumns(); + $cProcess->addSelectColumn( \AppCacheViewPeer::PRO_UID ); + $cProcess->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE ); + $cProcess->setDistinct( \AppCacheViewPeer::PRO_UID ); + if ($categoryUid) { + require_once 'classes/model/Process.php'; + $cProcess->addAlias( 'CP', 'PROCESS' ); + $cProcess->add( 'CP.PRO_CATEGORY', $categoryUid, Criteria::EQUAL ); + $cProcess->addJoin( \AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN ); + $cProcess->addAsColumn( 'CATEGORY_UID', 'CP.PRO_CATEGORY' ); + } + + $cProcess->addAscendingOrderByColumn(\AppCacheViewPeer::APP_PRO_TITLE); + + $oDataset = \AppCacheViewPeer::doSelectRS( $cProcess, \Propel::getDbConnection('workflow_ro') ); + $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + + while ($aRow = $oDataset->getRow()) { + $processes[] = array ($aRow['PRO_UID'],$aRow['APP_PRO_TITLE'] + ); + $oDataset->next(); + } + return $processes; + } + + /** + * lista de usuarios a reasignar + */ + public function getUsersToReassign($usr_uid, $task_uid) + { + //G::LoadClass( 'tasks' ); + G::LoadSystem( 'rbac' ); + G::LoadClass( 'memcached' ); + $memcache = \PMmemcached::getSingleton( SYS_SYS ); + $RBAC = \RBAC::getSingleton( PATH_DATA, session_id() ); + $RBAC->sSystem = 'PROCESSMAKER'; + $RBAC->initRBAC(); + $memKey = 'rbacSession' . session_id(); + if (($RBAC->aUserInfo = $memcache->get( $memKey )) === false) { + $RBAC->loadUserRolePermission( $RBAC->sSystem, $usr_uid ); + $memcache->set( $memKey, $RBAC->aUserInfo, \PMmemcached::EIGHT_HOURS ); + } + $GLOBALS['RBAC'] = $RBAC; + + $task = new \Task(); + $tasks = $task->load($task_uid); + $case = new \Cases(); + $result = new \stdclass(); + $result->data = $case->getUsersToReassign($task_uid, $usr_uid, $tasks['PRO_UID']); + return $result; + } + + /** + * + */ + public function reassignCase($usr_uid, $app_uid, $TO_USR_UID) + { + $cases = new \Cases(); + $user = new \Users(); + $app = new \Application(); + $result = new \stdclass(); + + try { + $iDelIndex = $cases->getCurrentDelegation( $app_uid, $usr_uid ); + $cases->reassignCase($app_uid, $iDelIndex, $usr_uid, $TO_USR_UID); + $caseData = $app->load($app_uid); + $userData = $user->load($TO_USR_UID); + $data['APP_NUMBER'] = $caseData['APP_NUMBER']; + $data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf + $result->status = 0; + $result->msg = G::LoadTranslation('ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data); + } catch (\Exception $e) { + $result->status = 1; + $result->msg = $e->getMessage(); + } + + return $result; + } + + /** + * + */ + public function pauseCase($usr_uid, $app_uid, $request_data) + { + $result = new \stdclass(); + + try { + $unpauseDate = $request_data['unpauseDate'] . ' '. $request_data['unpauseTime']; + $oCase = new \Cases(); + $iDelIndex = $oCase->getCurrentDelegation( $app_uid, $usr_uid ); + // Save the note pause reason + if ($request_data['noteContent'] != '') { + $request_data['noteContent'] = G::LoadTranslation('ID_CASE_PAUSE_LABEL_NOTE') . ' ' . $request_data['noteContent']; + $appNotes = new \AppNotes(); + $noteContent = addslashes($request_data['noteContent']); + $appNotes->postNewNote($app_uid, $usr_uid, $noteContent, $request_data['notifyUser']); + } + // End save + + $oCase->pauseCase($app_uid, $iDelIndex, $usr_uid, $unpauseDate); + $app = new \Application(); + $caseData = $app->load($app_uid); + $data['APP_NUMBER'] = $caseData['APP_NUMBER']; + $data['UNPAUSE_DATE'] = $unpauseDate; + + $result->success = true; + $result->msg = G::LoadTranslation('ID_CASE_PAUSED_SUCCESSFULLY', SYS_LANG, $data); + } catch (\Exception $e) { + throw $e; + } + return $result; + } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessMap.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessMap.php new file mode 100644 index 000000000..7685d656b --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessMap.php @@ -0,0 +1,801 @@ +running_case = array( + 'bpmnActivity' => $arrActivity, + ); + + //GET DIAGRAMS + $diagrams = $this->get_project_diagrams($schema['diagrams']); + foreach ($diagrams as $diagram) { + $files = $this->diagram_to_png($diagram); + } + } + return $files; + } + + /** + * Function to retrieve shapes of diagrams + * @param $prj_id + */ + private function get_project_diagrams($diagram) + { + $this->diagram = $diagram; + if (isset($diagram)) { + $response = array(); + foreach ($diagram as $row) { + $tmp = new \stdClass(); + $tmp->activities = $row['activities']; + $tmp->events = $row['events']; + $tmp->gateways = $row['gateways']; + $tmp->artifacts = $row['artifacts']; + $tmp->flows = $row['flows']; + $tmp->datas = $row['data']; + $tmp->participants = $row['participants']; + $tmp->laneset = $row['laneset']; + $tmp->lanes = $row['lanes']; + $response[] = $tmp; + } + return $response; + } + } + + private function diagram_to_png($diagram, $prj_name = '') + { + $serialize_data = serialize($diagram); + $data = unserialize($serialize_data); + $png_data = $this->convert_png_array($data); + //TODO: avoid hardcoded + $sprite_filename = PATH_HTML . 'lib/img/mafe_sprite.png'; + //TODO: avoid hardcoded + $sprite_filename_bw = PATH_HTML . 'lib/img/mafe_sprite.png'; + $image_sprite = imagecreatefrompng($sprite_filename); + $image_sprite_bw = imagecreatefrompng($sprite_filename_bw); + $sprite_map = $this->load_sprite_coords(); + + $image = $this->allocate_diagram_image($png_data, $sprite_map, $image_sprite, $image_sprite_bw); + + return $image; + } + + private function convert_png_array($data) + { + $pngArray = array(); + + foreach ($data->participants as $participants) { + $tmpData = array(); + $tmpData[0] = 'bpmnParticipant'; + $tmpData[1] = $participants['bou_x']; + $tmpData[2] = $participants['bou_y']; + $tmpData[3] = $participants['bou_width']; + $tmpData[4] = $participants['bou_height']; + $tmpData[5] = ""; + $tmpData[6] = $participants['par_name']; + $tmpData[7] = ""; + $tmpData[8] = $participants['par_uid']; + $pngArray[] = $tmpData; + } + + foreach ($data->laneset as $laneset) { + $tmpData = array(); + $tmpData[0] = 'bpmnPool'; + $tmpData[1] = $laneset['bou_x']; + $tmpData[2] = $laneset['bou_y']; + $tmpData[3] = $laneset['bou_width']; + $tmpData[4] = $laneset['bou_height']; + $tmpData[5] = $laneset['dat_type']; + $tmpData[6] = $laneset['lns_name']; + $tmpData[7] = ""; + $tmpData[8] = $laneset['lns_uid']; + $pngArray[] = $tmpData; + } + + foreach ($data->lanes as $lanes) { + $tmpData = array(); + $tmpData[0] = 'bpmnLane'; + $tmpData[1] = $lanes['bou_x']; + $tmpData[2] = $lanes['bou_y']; + $tmpData[3] = $lanes['bou_width']; + $tmpData[4] = $lanes['bou_height']; + $tmpData[5] = ""; + $tmpData[6] = $lanes['lan_name']; + $tmpData[7] = ""; + $tmpData[8] = $lanes['lan_uid']; + $tmpData[9] = ""; + + $tmpData[10] = $lanes['bou_container']; + $tmpData[11] = $lanes['bou_element']; + $pngArray[] = $tmpData; + } + + foreach ($data->activities as $activity) { + $tmpData = array(); + $tmpData[0] = 'bpmnActivity'; + $tmpData[1] = $activity['bou_x']; + $tmpData[2] = $activity['bou_y']; + $tmpData[3] = $activity['bou_width']; + $tmpData[4] = $activity['bou_height']; + $tmpData[5] = $activity['act_type']; + $tmpData[6] = $activity['act_name']; + $tmpData[7] = $activity['act_task_type'] . '_' . $activity['act_loop_type'] . '_' . $activity['act_is_adhoc'] . '_' . $activity['act_is_collapsed']; + $tmpData[8] = $activity['act_uid']; + $tmpData[9] = $activity['act_script_type']; + + $tmpData[10] = $activity['bou_container']; + $tmpData[11] = $activity['bou_element']; + + $pngArray[] = $tmpData; + } + + foreach ($data->events as $event) { + $tmpData = array(); + $tmpData[0] = 'bpmnEvent'; + $tmpData[1] = $event['bou_x']; + $tmpData[2] = $event['bou_y']; + $tmpData[3] = $event['bou_width']; + $tmpData[4] = $event['bou_height']; + if ($event['evn_type'] == 'BOUNDARY') { + $tmpData[5] = $event['evn_is_interrupting'] . '_INTERMEDIATE_EVENT'; + } else { + $tmpData[5] = $event['evn_is_interrupting'] . '_' . $event['evn_type'] . '_EVENT'; + } + $tmpData[6] = $event['evn_name']; + if ($event['evn_type'] == 'BOUNDARY') { + $tmpData[7] = 'INTERMEDIATE_' . $event['evn_marker'] . '_' . $event['evn_behavior']; + } else if ($event['evn_type'] == 'INTERMEDIATE') { + if ($event['evn_marker'] == 'EMPTY') { + $tmpData[7] = 'EMPTY'; + } else { + if ($event['evn_behavior'] != '') { + $tmpData[7] = $event['evn_type'] . '_' . $event['evn_marker'] . '_' . $event['evn_behavior']; + } else { + $tmpData[7] = $event['evn_type'] . '_' . $event['evn_marker']; + } + } + } else { + if ($event['evn_marker'] == 'EMPTY') { + $tmpData[7] = 'EMPTY'; + } else { + if ($event['evn_message'] != '') { + $tmpData[7] = $event['evn_type'] . '_' . $event['evn_marker'] . '_' . $event['evn_message']; + } else { + $tmpData[7] = $event['evn_type'] . '_' . $event['evn_marker']; + } + } + } + $tmpData[8] = $event['evn_uid']; + $tmpData[9] = ""; + + $tmpData[10] = $event['bou_container']; + $tmpData[11] = $event['bou_element']; + $pngArray[] = $tmpData; + } + + foreach ($data->gateways as $gateway) { + $tmpData = array(); + $tmpData[0] = 'bpmnGateway'; + $tmpData[1] = $gateway['bou_x']; + $tmpData[2] = $gateway['bou_y']; + $tmpData[3] = $gateway['bou_width']; + $tmpData[4] = $gateway['bou_height']; + $tmpData[5] = $gateway['gat_type'] . '_GATEWAY'; + $tmpData[6] = $gateway['gat_name']; + $tmpData[7] = ''; + $tmpData[8] = $gateway['gat_uid']; + $tmpData[9] = ''; + $tmpData[10] = $gateway['bou_container']; + $tmpData[11] = $gateway['bou_element']; + $pngArray[] = $tmpData; + } + + foreach ($data->artifacts as $artifact) { + $tmpData = array(); + $tmpData[0] = 'bpmnArtifact'; + $tmpData[1] = $artifact['bou_x']; + $tmpData[2] = $artifact['bou_y']; + $tmpData[3] = $artifact['bou_width']; + $tmpData[4] = $artifact['bou_height']; + $tmpData[5] = $artifact['art_name']; + $tmpData[6] = $artifact['art_type']; + $tmpData[7] = ''; + $tmpData[8] = $artifact['art_uid']; + $tmpData[9] = ''; + $tmpData[10] = $artifact['bou_container']; + $tmpData[11] = $artifact['bou_element']; + $pngArray[] = $tmpData; + } + + foreach ($data->flows as $flow) { + $tmpData = array(); + $tmpData[0] = 'bpmnFlow'; + $tmpData[1] = $flow['flo_name']; + $tmpData[2] = $flow['flo_type']; + $tmpData[3] = $flow['flo_element_origin_type']; + $tmpData[4] = "";//$flow['flo_element_origin_port']; + $tmpData[5] = $flow['flo_element_dest_type']; + $tmpData[6] = "";//$flow['flo_element_dest_port']; + $tmpData[7] = $flow['flo_element_origin']; + $tmpData[8] = $flow['flo_element_dest']; + $tmpData[9] = $flow['flo_state']; + $pngArray[] = $tmpData; + } + + foreach ($data->datas as $data) { + $tmpData = array(); + $tmpData[0] = 'bpmnData'; + $tmpData[1] = $data['bou_x']; + $tmpData[2] = $data['bou_y']; + $tmpData[3] = $data['bou_width']; + $tmpData[4] = $data['bou_height']; + $tmpData[5] = $data['dat_type']; + $tmpData[6] = $data['dat_name']; + $tmpData[7] = ""; + $tmpData[8] = $data['dat_uid']; + $tmpData[9] = ''; + $tmpData[10] = $data['bou_container']; + $tmpData[11] = $data['bou_element']; + $pngArray[] = $tmpData; + } + + return $pngArray; + } + + private function load_sprite_coords() + { + $xMap = array(); + $xMap['1_START_EVENT'] = array(0, 4759); + $xMap['START_MESSAGECATCH_LEAD'] = array(0, 9371); + $xMap['START_TIMER_LEAD'] = array(0, 8872); + $xMap['START_CONDITIONAL_LEAD'] = array(0, 9180); + $xMap['START_SIGNALCATCH_LEAD'] = array(0, 8905); + $xMap['INTERMEDIATE_MESSAGETHROW_THROW'] = array(0, 8987); +// $xMap['INTERMEDIATE_LINKTHROW_THROW'] = array(0, 4887); +// $xMap['INTERMEDIATE_COMPENSATIONTHROW_THROW'] = array(0, 4260); + $xMap['INTERMEDIATE_SIGNALTHROW_THROW'] = array(0, 9338); + $xMap['INTERMEDIATE_MESSAGECATCH_CATCH'] = array(0, 9213); + $xMap['INTERMEDIATE_TIMER_CATCH'] = array(0, 8704); + $xMap['INTERMEDIATE_CONDITIONAL_CATCH'] = array(0, 9053); +// $xMap['INTERMEDIATE_LINKCATCH_CATCH'] = array(0, 4648); + $xMap['INTERMEDIATE_SIGNALCATCH_CATCH'] = array(0, 9246); + + $xMap['1_END_EVENT'] = array(0, 4832); + $xMap['END_MESSAGETHROW'] = array(0, 9486); + $xMap['END_ERRORTHROW'] = array(0, 9545); + $xMap['END_CANCELTHROW'] = array(0, 5125); + $xMap['END_COMPENSATIONTHROW'] = array(0, 5473); + $xMap['END_SIGNALTHROW'] = array(0, 9657); + $xMap['END_TERMINATETHROW'] = array(0, 9609); + + $xMap['EXCLUSIVE_GATEWAY'] = array(0, 2624); + $xMap['PARALLEL_GATEWAY'] = array(0, 3301); + $xMap['INCLUSIVE_GATEWAY'] = array(0, 2369); +// $xMap['EVENTBASED_GATEWAY'] = array(0, 2753); +// $xMap['COMPLEX_GATEWAY'] = array(0, 4394); + + $xMap['TASK_SENDTASK'] = array(0, 10468); + $xMap['TASK_RECEIVETASK'] = array(0, 10219); + $xMap['TASK_USERTASK'] = array(0, 4453); + $xMap['TASK_SERVICETASK'] = array(0, 8439); + $xMap['TASK_SCRIPTTASK'] = array(0, 8851); + $xMap['TASK_MANUALTASK'] = array(0, 9777); + $xMap['TASK_BUSINESSRULE'] = array(0, 10561); + $xMap['LOOP_LOOP'] = array(0, 5654); + $xMap['LOOP_PARALLEL'] = array(0, 7108); + $xMap['LOOP_SEQUENTIAL'] = array(0, 7036); + + $xMap['DATAOBJECT'] = array(0, 5401); + $xMap['DATAINPUT'] = array(0, 5791); + $xMap['DATAOUTPUT'] = array(0, 6071); + $xMap['DATASTORE'] = array(0, 3037); + + + $xMap['arrow_target_right'] = array(0, 6727); + $xMap['arrow_target_left'] = array(0, 6774); + $xMap['arrow_target_top'] = array(0, 6819); + $xMap['arrow_target_bottom'] = array(0, 6852); + + $xMap['arrow_conditional_source_right'] = array(0, 99); + $xMap['arrow_conditional_source_left'] = array(0, 99); + $xMap['arrow_conditional_source_top'] = array(0, 111); + $xMap['arrow_conditional_source_bottom'] = array(0, 111); + + $xMap['arrow_default_source_right'] = array(0, 6893); + $xMap['arrow_default_source_left'] = array(0, 6910); + $xMap['arrow_default_source_top'] = array(0, 6863); + $xMap['arrow_default_source_bottom'] = array(0, 6882); + + $xMap['text_now'] = array(0, 0); + $xMap['icon_terminated'] = array(0, 10); + return $xMap; + } + + private function allocate_diagram_image(array $pngData, $xSpriteMap, $imgSprite, $imgSpriteBW = '') + { + $font = PATH_HTML .'lib/fonts/Chivo/Chivo-Regular.ttf'; + $minX = 10000; + $minY = 10000; + $maxW = 0; + $maxH = 0; + $border = 40; + + foreach ($pngData as $coords) { + if ($coords[0] !== 'bpmnFlow') { + if ($minX > $coords[1]) { + $minX = $coords[1]; + } + if ($minY > $coords[2]) { + $minY = $coords[2]; + } + if ($maxW < ($coords[1] + $coords[3])) { + $maxW = $coords[1] + $coords[3]; + } + if ($maxH < ($coords[2] + $coords[4])) { + $maxH = $coords[2] + $coords[4]; + } + } + } + + $x1 = $minX - $border; + $y1 = $minY - $border; + $x2 = $maxW + $border; + $y2 = $maxH + $border; + $cWidth = $x2 - $x1; + $cHeight = $y2 - $y1; + + if ($cWidth < 0 && $cHeight < 0) { + $cWidth = 100; + $cHeight = 100; + } + + $img = imagecreatetruecolor($cWidth, $cHeight); + + $white = imagecolorallocate($img, 255, 255, 255); + $black = imagecolorallocate($img, 0, 0, 0); + $groupColor = imagecolorallocate($img, 153, 94, 6); + $gray = imagecolorallocate($img, 0xC0, 0xC0, 0xC0); + $aNotSupportedColor = imagecolorallocate($img, 59, 71, 83); + $aNotSupportedFillColor = $white; + + imagefill($img,0,0,$white); + foreach ($pngData as $figure) { + $shape_running = $this->get_shape_process($figure[8], $figure[0], $img); + $shape_image = $imgSprite ; + $aTaskColor = isset($shape_running->colors['color']) ? $shape_running->colors['color'] : imagecolorallocate($img, 59, 71, 83); + $aTaskFillColor = isset($shape_running->colors['fillcolor']) ? $shape_running->colors['fillcolor'] : imagecolorallocate($img, 255, 255, 255); + switch ($figure[0]) { + case 'bpmnParticipant': + case 'bpmnPool': + $X1 = $figure[1] - $x1; + $Y1 = $figure[2] - $y1; + $X2 = $X1 + $figure[3]; + $Y2 = $Y1 + $figure[4]; + $points = array($X1 + 3, $Y1, $X2 - 3, $Y1, $X2, $Y1 + 3, $X2, $Y2 - 3, $X2 - 3, $Y2, $X1 + 3, $Y2, $X1, $Y2 - 3, $X1, $Y1 + 3); + $borderColor = $aNotSupportedColor; + $fillColor = $aNotSupportedFillColor; + imagesetthickness($img, 3); + + imagefilledpolygon($img, $points, 8, $fillColor); + imagepolygon($img, $points, 8, $borderColor); + imageline ( $img , $X1+40 , $Y1 , $X1+40 , $Y2 , $aTaskColor ); + //Print Text + if (isset($figure[9]) && $figure[9] != '') { + $tt = explode('_', $figure[7]); + $this->print_text($img, $figure[6], 10, 90, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0], $tt[0]); + } else { + $this->print_text($img, $figure[6], 10, 90, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0], $figure[5]); + } + break; + case 'bpmnLane': + $newPoints = $this->getNewPoints($figure[11],$figure[10]); + + $X1 = $figure[1] - $x1 + $newPoints[0]; + $Y1 = $figure[2] - $y1 + $newPoints[1]; + $X2 = $X1 + $figure[3]; + $Y2 = $Y1 + $figure[4]; + $points = array($X1 + 3, $Y1, $X2 - 3, $Y1, $X2, $Y1 + 3, $X2, $Y2 - 3, $X2 - 3, $Y2, $X1 + 3, $Y2, $X1, $Y2 - 3, $X1, $Y1 + 3); + $borderColor = $aNotSupportedColor; + $fillColor = $aNotSupportedFillColor; + imagesetthickness($img, 3); + + imagefilledpolygon($img, $points, 8, $fillColor); + imagepolygon($img, $points, 8, $borderColor); + + if (isset($figure[9]) && $figure[9] != '') { + $tt = explode('_', $figure[7]); + $this->print_text($img, $figure[6], 10, 90, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0], $tt[0]); + } else { + $this->print_text($img, $figure[6], 10, 90, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0], $figure[5]); + } + break; + case 'bpmnActivity': + $newPoints = $this->getNewPoints($figure[11],$figure[10]); + $X1 = $figure[1] - $x1 + $newPoints[0]; + $Y1 = $figure[2] - $y1 + $newPoints[1]; + $X2 = $X1 + $figure[3]; + $Y2 = $Y1 + $figure[4]; + $properties = explode('_', $figure[7]); + $points = array($X1 + 3, $Y1, $X2 - 3, $Y1, $X2, $Y1 + 3, $X2, $Y2 - 3, $X2 - 3, $Y2, $X1 + 3, $Y2, $X1, $Y2 - 3, $X1, $Y1 + 3); + $points2 = array($X1 + 5, $Y1 + 2, $X2 - 5, $Y1 + 2, $X2 - 2, $Y1 + 5, $X2 - 2, $Y2 - 5, $X2 - 5, $Y2 - 2, $X1 + 5, $Y2 - 2, $X1 + 2, $Y2 - 5, $X1 + 2, $Y1 + 5); + switch ($figure[5]) { + case 'TASK': + $borderColor = $aTaskColor; + $fillColor = $aTaskFillColor; + imagesetthickness($img, 2); + break; + default: + $borderColor = $aNotSupportedColor; + $fillColor = $aNotSupportedFillColor; + imagesetthickness($img, 4); + } + //CURRENT CASE + if ($shape_running->running) { + $points_active = array($X1 + 3, $Y1, $X2 - 3, $Y1, $X2, $Y1 + 3, $X2, $Y2 - 3, $X2 - 3, $Y2, $X1 + 3, $Y2, $X1, $Y2 - 3, $X1, $Y1 + 3); + imagefilledpolygon($img, $points, 8, $fillColor); + imagepolygon($img, $points_active, 8, $borderColor); + } else { + imagefilledpolygon($img, $points, 8, $fillColor); + imagepolygon($img, $points, 8, $borderColor); + } + //Task Type + if ($figure[5] == 'TASK' || $figure[5] == 'TASKCALLACTIVITY') { + if (isset($figure[9]) && $figure[9] != '') { + $css = 'scripttask_' . strtolower($figure[9]); + $spriteCoords = $xSpriteMap[$css]; + imagecopy($img, $shape_image, $figure[1] - $x1 - 2 + $newPoints[0], $figure[2] - $y1 - 2 + $newPoints[1], $spriteCoords[0], $spriteCoords[1], 39, 39); + } elseif ($properties[0] != "EMPTY") { + $css = 'TASK_' . strtoupper($properties[0]); + $spriteCoords = $xSpriteMap[$css]; + imagecopy($img, $shape_image, $figure[1] - $x1 + 4 + $newPoints[0], $figure[2] - $y1 + 4 + $newPoints[1], $spriteCoords[0], $spriteCoords[1], 21, 21); + } + } + //Makers + if ($figure[5] == 'TASK' && ($properties[1] != 'NONE' && $properties[1] != 'EMPTY')) { + $css = 'LOOP_' . strtoupper($properties[1]); + $spriteCoords = $xSpriteMap[$css]; + imagecopy($img, $shape_image, $figure[1] - $x1 + $newPoints[0] + ($figure[3] - 21) / 2, $figure[2] - $y1 + $newPoints[1] + $figure[4] - 23, $spriteCoords[0], $spriteCoords[1], 21, 21); + } + //Print Text + if (isset($figure[9]) && $figure[9] != '') { + $tt = explode('_', $figure[7]); + $this->print_text($img, $figure[6], 10, 0, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0], $tt[0]); + } else { + $this->print_text($img, $figure[6], 10, 0, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0], $figure[5]); + } + break; + case 'bpmnEvent': + $newPoints = $this->getNewPoints($figure[11],$figure[10]); + $X1 = $figure[1] - $x1 + $newPoints[0]; + $Y1 = $figure[2] - $y1 + $figure[4] - 10 + $newPoints[1]; + $X2 = $X1 + $figure[3]; + $Y2 = $Y1 + $figure[4] + 5; + $css = $figure[5]; + $marker = $figure[7]; + $spriteCoords = ($marker != 'EMPTY')?$xSpriteMap[$marker]:$xSpriteMap[$css]; + $mk = explode('_', $figure[7]); + //CURRENT CASE + imagecopy($img, $shape_image, $figure[1] - $x1 + $newPoints[0], $figure[2] - $y1 + $newPoints[1], $spriteCoords[0], $spriteCoords[1], $figure[3], $figure[4]); + + if ($marker != 'EMPTY') { + //END_CANCELTHROW??? + if (isset($xSpriteMap[$marker])) { + $spriteCoords2 = $xSpriteMap[$marker]; + if (!($shape_running->running && $mk[1] == 'TIMER')) { + imagecopy($img, $shape_image, $figure[1] - $x1 + $newPoints[0], $figure[2] - $y1 + $newPoints[1], $spriteCoords2[0], $spriteCoords2[1], $figure[3], $figure[4]); + } + } + } + $this->print_text($img, $figure[6], 10, 0, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0]); + break; + case 'bpmnGateway': + $newPoints = $this->getNewPoints($figure[11],$figure[10]); + $X1 = $figure[1] - $x1 + $newPoints[0]; + $Y1 = $figure[2] - $y1 + $figure[4] - 10 + $newPoints[1]; + $X2 = $X1 + $figure[3]; + $Y2 = $Y1 + $figure[4] + 5; + $css = $figure[5]; + $spriteCoords = $xSpriteMap[$css]; + imagecopy($img, $shape_image, $figure[1] - $x1 + $newPoints[0], $figure[2] - $y1 + $newPoints[1], $spriteCoords[0], $spriteCoords[1], $figure[3], $figure[4]); + $this->print_text($img, $figure[6], 10, 0, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0]); + break; + case 'bpmnArtifact': + $newPoints = $this->getNewPoints($figure[11],$figure[10]); + $xX1 = $figure[1] - $x1 + $newPoints[0]; + $xY1 = $figure[2] - $y1 + $newPoints[1]; + $xX2 = $xX1 + $figure[3]; + $xY2 = $xY1 + $figure[4]; + + if ($figure[6] == 'GROUP') { + imagesetthickness($img, 2); + $style = array( + $groupColor, $groupColor, $groupColor, $groupColor, $groupColor, + $white, $white, $white, $white, $white + ); + imagesetstyle($img, $style); + imageline($img, $xX1, $xY1, $xX2, $xY1, IMG_COLOR_STYLED); + imageline($img, $xX2, $xY1, $xX2, $xY2, IMG_COLOR_STYLED); + imageline($img, $xX2, $xY2, $xX1, $xY2, IMG_COLOR_STYLED); + imageline($img, $xX1, $xY2, $xX1, $xY1, IMG_COLOR_STYLED); + $this->print_text($img, $figure[5], 10, 0, $black, $font, $xX1, $xY1 - 5, $xX2, $xY2, $figure[0], $figure[5]); + } + if ($figure[6] == 'TEXT_ANNOTATION') { + imagesetthickness($img, 1); + imageline($img, $xX1, $xY1, $xX1, $xY2, $black); + imageline($img, $xX1, $xY1, $xX1 + 15, $xY1, $black); + imageline($img, $xX1, $xY2, $xX1 + 15, $xY2, $black); + $this->print_text($img, $figure[5], 10, 0, $black, $font, $xX1, $xY1, $xX2, $xY2, $figure[0], $figure[6]); + } + break; //this break wasn't here ... + case 'bpmnData': + $newPoints = $this->getNewPoints($figure[11],$figure[10]); + $X1 = $figure[1] - $x1 + $newPoints[0]; + $Y1 = $figure[2] - $y1 + $figure[4] - 10 + $newPoints[1]; + $X2 = $X1 + $figure[3]; + $Y2 = $Y1 + $figure[4] + 5; + $css = $figure[5]; + $spriteCoords = $xSpriteMap[$css]; + imagecopy($img, $shape_image, $figure[1] - $x1 + $newPoints[0], $figure[2] - $y1 + $newPoints[1], $spriteCoords[0], $spriteCoords[1], $figure[3], $figure[4]); + $this->print_text($img, $figure[6], 10, 0, $black, $font, $X1, $Y1, $X2, $Y2, $figure[0]); + break; + case 'bpmnFlow': + $X1 = $figure[1] - $x1 ; + $Y1 = $figure[2] - $y1 ; + $X2 = $X1 + $figure[3]; + $Y2 = $Y1 + $figure[4]; + imagesetthickness($img, 1); + $lines = $figure[9]; + $shape_o = $this->get_shape_process($figure[7], $figure[3]); + $shape_d = $this->get_shape_process($figure[8], $figure[5]); +// if ($shape_o->in_flow && $shape_d->in_flow) { + $line_color = $black; + $shape_image = $imgSprite; +// } else { +// $line_color = $gray; +// $shape_image = $imgSpriteBW; +// } + foreach ($lines as $key => $segment) { + if (isset($lines[$key + 1]) && $lines[$key + 1]['x'] != '' && $lines[$key + 1]['y'] != '') { + if ($figure[2] == 'MESSAGE' || $figure[2] == 'ASSOCIATION' || $figure[2] == 'DATAASSOCIATION') { + $style = array( + $black, $black, $black, $black, + $white, $white, $white, $white + ); + imagesetstyle($img, $style); + imageline($img, $lines[$key]['x'] - $x1, $lines[$key]['y'] - $y1, $lines[$key + 1]['x'] - $x1, $lines[$key + 1]['y'] - $y1, IMG_COLOR_STYLED); + } else { + imageline($img, $lines[$key]['x'] - $x1, $lines[$key]['y'] - $y1, $lines[$key + 1]['x'] - $x1, $lines[$key + 1]['y'] - $y1, $line_color); + } + if ((int) ((sizeof($lines) - 1) / 2) == $key) { + $this->print_text($img, $figure[1], 10, 0, $black, $font, $lines[$key]['x'] - $x1, $lines[$key]['y'] - $y1, $lines[$key + 1]['x'] - $x1, $lines[$key + 1]['y'] - $y1, $figure[0]); + } + } + } + + $decorator_width = 11; + $decorator_height = 11; + //END DECORATOR + + if ($lines[sizeof($lines) - 1]['x'] == $lines[sizeof($lines) - 2]['x']) { + if ($lines[sizeof($lines) - 1]['y'] < $lines[sizeof($lines) - 2]['y']) { + $spriteCoords = $xSpriteMap['arrow_target_bottom']; + imagecopy($img, $shape_image, $lines[sizeof($lines) - 1]['x'] - (int) ($decorator_width / 2) - $x1, $lines[sizeof($lines) - 1]['y'] - $y1, $spriteCoords[0], $spriteCoords[1], $decorator_width, $decorator_height); + } else { + $spriteCoords = $xSpriteMap['arrow_target_top']; + imagecopy($img, $shape_image, $lines[sizeof($lines) - 1]['x'] - (int) ($decorator_width / 2) - $x1, $lines[sizeof($lines) - 1]['y'] - $decorator_height - $y1, $spriteCoords[0], $spriteCoords[1], $decorator_width, $decorator_height); + } + } elseif (($lines[sizeof($lines) - 1]['y'] == $lines[sizeof($lines) - 2]['y'])) { + if ($lines[sizeof($lines) - 1]['x'] < $lines[sizeof($lines) - 2]['x']) { + $spriteCoords = $xSpriteMap['arrow_target_right']; + imagecopy($img, $shape_image, $lines[sizeof($lines) - 1]['x'] - $x1, $lines[sizeof($lines) - 1]['y'] - (int) ($decorator_height / 2) - $y1, $spriteCoords[0], $spriteCoords[1], $decorator_width, $decorator_height); + } else { + $spriteCoords = $xSpriteMap['arrow_target_left']; + imagecopy($img, $shape_image, $lines[sizeof($lines) - 1]['x'] - $decorator_width - $x1, $lines[sizeof($lines) - 1]['y'] - (int) ($decorator_height / 2) - $y1, $spriteCoords[0], $spriteCoords[1], $decorator_width, $decorator_height); + } + } + + //SOURCE DECORATOR + if ($figure[2] === 'DEFAULT' OR $figure[2] === 'CONDITIONAL') { + if ($figure[2] === 'DEFAULT') { + $source_decorator = '_default'; + } elseif ($figure[2] === 'CONDITIONAL') { + $source_decorator = '_conditional'; + } + + if ($lines[0]['x'] == $lines[1]['x']) { + if ($lines[0]['y'] < $lines[1]['y']) { + $spriteCoords = $xSpriteMap['arrow' . $source_decorator . '_source_top']; + imagecopy($img, $shape_image, $lines[0]['x'] - (int) ($decorator_width / 2) - $x1, $lines[0]['y'] - $y1, $spriteCoords[0], $spriteCoords[1], $decorator_width, $decorator_height); + } else { + $spriteCoords = $xSpriteMap['arrow' . $source_decorator . '_source_bottom']; + imagecopy($img, $shape_image, $lines[0]['x'] - (int) ($decorator_width / 2) - $x1, $lines[0]['y'] - $decorator_height - $y1, $spriteCoords[0], $spriteCoords[1], $decorator_width, $decorator_height); + } + } elseif (($lines[0]['y'] == $lines[1]['y'])) { + if ($lines[0]['x'] < $lines[1]['x']) { + $spriteCoords = $xSpriteMap['arrow' . $source_decorator . '_source_right']; + imagecopy($img, $shape_image, $lines[0]['x'] - $x1, $lines[0]['y'] - (int) ($decorator_height / 2) - $y1, $spriteCoords[0], $spriteCoords[1], $decorator_width, $decorator_height); + } else { + $spriteCoords = $xSpriteMap['arrow' . $source_decorator . '_source_left']; + imagecopy($img, $shape_image, $lines[0]['x'] - $decorator_width - $x1, $lines[0]['y'] - (int) ($decorator_height / 2) - $y1, $spriteCoords[0], $spriteCoords[1], $decorator_width, $decorator_height); + } + } + } + break; + } + } + return $img; + } + + private function get_shape_process($id, $shape, $img = null) + { + $result = new \stdClass(); + $result->running = false; + $process_route = $this->running_case; + if ($shape != 'bpmnFlow') { + if (isset($process_route[$shape]) && array_key_exists($id, $process_route[$shape])) { + $result->status = $process_route[$shape][$id]; + $result->colors = $this->get_shape_process_color($process_route[$shape][$id], $img); + $result->running = true; + } + } + return $result; + } + + private function get_shape_process_color($status, $img) + { + $img = is_null($img) ? imagecreate(10,10):$img; + $red = imagecolorallocate($img, 189, 10, 23); + $red_1 = imagecolorallocate($img, 114, 2, 12); + $orange = imagecolorallocate($img, 197, 119, 1); + $orange_1 = imagecolorallocate($img, 150, 91, 2); + $silver = imagecolorallocate($img, 170, 168, 166); + $silver_1 = imagecolorallocate($img, 111, 109, 108); + $green = imagecolorallocate($img, 27, 121, 9); + $green_1 = imagecolorallocate($img, 15, 85, 2); + $white = imagecolorallocate($img, 59, 71, 83); + $white_1 = imagecolorallocate($img, 255, 255, 255); + + $result = array(); + switch ($status) { + case 'TASK_IN_PROGRESS'://red + $result['fillcolor'] = $red; + $result['color'] = $red_1; + break; + case 'TASK_COMPLETED'://green + $result['fillcolor'] = $green; + $result['color'] = $green_1; + break; + case 'TASK_PENDING_NOT_EXECUTED'://silver + $result['fillcolor'] = $silver; + $result['color'] = $silver_1; + break; + case 'TASK_PARALLEL'://orange + $result['fillcolor'] = $orange; + $result['color'] = $orange_1; + break; + default: + $result['fillcolor'] = $white; + $result['color'] = $white_1; + break; + } + return $result; + } + + private function getNewPoints($idElement, $elementName) + { + $defenitions = array( + 'bpmnParticipant' => 'participants', + 'bpmnPool' => 'laneset', + 'bpmnLane' => 'lanes', + 'bpmnActivity' => 'activities', + 'bpmnEvent' => 'events', + 'bpmnGateway' => 'gateways', + 'bpmnArtifact' => 'artifacts', + 'bpmnData' => 'datas' + ); + + $result = array(0,0); + $resRec = array(0,0); + if(isset($defenitions[$elementName])){ + $name = $defenitions[$elementName]; + foreach($this->diagram as $schem){ + $elements = $schem[$name]; + foreach ($elements as $element) { + if($element['bou_container'] != "bpmnDiagram"){ + $resRec = $this->getNewPoints($element['bou_element'],$element['bou_container']); + } + if($element['lns_uid'] == $idElement || $element['lan_uid'] == $idElement){ + $result = array($element['bou_x'] + $resRec[0],$element['bou_y'] + $resRec[1]); + } + } + } + } + + return $result; + } + + private function print_text($IMG, $txt, $size, $angle, $color, $font, $x1, $y1, $x2, $y2, $type = '', $stype = '') + { + //TODO Create a section to write multi-line text + $yy = 0; + switch ($type) { + case 'bpmnActivity': + case 'bpmnArtifact': + if ($stype == 'SCRIPTTASK') { + $line = $this->wrap_text($size, $angle, $font, $txt, $x2 + 50 - $x1); + } else { + $line = $this->wrap_text($size, $angle, $font, $txt, $x2 - $x1); + } + break; + case 'bpmnEvent': + $line = $this->wrap_text($size, $angle, $font, $txt, $x2 + 40 - $x1); + break; + case 'bpmnGateway': + $line = $this->wrap_text($size, $angle, $font, $txt, $x2 + 40 - $x1); + break; + case 'bpmnPool': + case 'bpmnParticipant': + case 'bpmnLane': + $line = $this->wrap_text($size, $angle, $font, $txt, $y2 + 40 - $y1); + break; + default: + $line = $this->wrap_text($size, $angle, $font, $txt, $x2 - $x1); + } + $h = count($line) * 16; + foreach ($line as $value) { + $w = strlen(trim($value))*6; + $X = ($x1 + ((($x2 - $x1) - $w) / 2)) - 5; + if ($type == 'bpmnActivity' && $stype == 'TASK') { + $Y = $y1 + (($y2 - $y1)/2) - floor($h/2) + $yy + 10; + } else if ($type == 'bpmnArtifact' && $stype == 'TEXT_ANNOTATION') { + $Y = $y1 + (($y2 - $y1)/2) - floor($h/2) + $yy + 10; + } else if ($type == 'bpmnActivity' && $stype == 'SCRIPTTASK') { + $Y = $y2 + $yy + 100; + } else if ($type == 'bpmnPool' || $type == 'bpmnParticipant' || $type == 'bpmnLane') { + $X = $x1 + $yy + 25; + $Y = ($y2 - ((($y2 - $y1) - $w) / 2)); + } else if ($type == 'bpmnFlow') { + $Y = $y1 + $yy + 15; + } else { + $Y = $y1 + $yy + 25; + } + imagettftext($IMG, $size, $angle, $X, $Y, $color, $font, $value); + $yy += 16; + } + } + + private function wrap_text($fontSize, $angle, $fontFace, $string, $width) + { + $pattern = '[\n|\r|\n\r]'; + $string = preg_replace($pattern, ' ', trim($string)); + $arr = explode(' ', $string); + $sa = ''; + $sf = array(); + foreach ($arr as $word) { + $sa_ = $sa; + $sa .= ' ' . $word; + $w = strlen(trim($sa))*6; + if ($w >= $width) { + $sf[] = $sa_; + $sa = $word; + } + } + $sf[] = $sa; + return $sf; + } +} diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Light.php b/workflow/engine/src/ProcessMaker/Services/Api/Light.php index 5ae04b00a..1fcd65d68 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Light.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Light.php @@ -3,7 +3,7 @@ namespace ProcessMaker\Services\Api; use \G; - +use \ProcessMaker\Project\Adapter; use \ProcessMaker\Services\Api; use \Luracast\Restler\RestException; @@ -487,11 +487,10 @@ class Light extends Api $activitySteps = $task->getSteps($act_uid); - //$step = new \ProcessMaker\Services\Api\Project\Activity\Step(); - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); $dynaForm->setFormatFieldNameInUppercase(false); - + $oMobile = new \ProcessMaker\BusinessModel\Light(); + $step = new \ProcessMaker\Services\Api\Project\Activity\Step(); $response = array(); for ($i = 0; $i < count($activitySteps); $i++) { if ($activitySteps[$i]['step_type_obj'] == "DYNAFORM") { @@ -499,7 +498,9 @@ class Light extends Api $result = $this->parserDataDynaForm($dataForm); $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null)?json_decode($result['formContent']):""; $result['index'] = $i; - //$activitySteps[$i]["triggers"] = $step->doGetActivityStepTriggers($activitySteps[$i]["step_uid"], $act_uid, $prj_uid); + $result['stepId'] = $activitySteps[$i]["step_uid"]; + $trigger = $oMobile->statusTriggers($step->doGetActivityStepTriggers($activitySteps[$i]["step_uid"], $act_uid, $prj_uid)); + $result["triggers"] = $trigger; $response[] = $result; } } @@ -509,6 +510,41 @@ class Light extends Api return $response; } + /** + * Execute Trigger case + * + * @param string $prj_uid {@min 1}{@max 32} + * @param string $act_uid {@min 1}{@max 32} + * @param string $cas_uid {@min 1}{@max 32} + * @param string $step_uid {@min 32}{@max 32} + * @param string $type {@choice before,after} + * + * @copyright Colosa - Bolivia + * + * @url POST /process/:prj_uid/task/:act_uid/case/:cas_uid/step/:step_uid/execute-trigger/:type + */ + public function doPutExecuteTriggerCase($prj_uid, $act_uid, $cas_uid, $step_uid, $type) + { + try { + $userUid = $this->getUserId(); + $step = new \ProcessMaker\Services\Api\Project\Activity\Step(); + $triggers= $step->doGetActivityStepTriggers($step_uid, $act_uid, $prj_uid); + + $step = new \ProcessMaker\BusinessModel\Step(); + $step->setFormatFieldNameInUppercase(false); + $step->setArrayParamException(array("stepUid" => "step_uid", "taskUid" => "act_uid", "processUid" => "prj_uid")); + + $cases = new \ProcessMaker\BusinessModel\Cases(); + foreach($triggers as $trigger){ + if (strtolower($trigger['st_type']) == $type) { + $cases->putExecuteTriggerCase($cas_uid, $trigger['tri_uid'], $userUid); + } + } + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + /** * @url GET /project/dynaform/:dyn_uid * @@ -810,4 +846,275 @@ class Light extends Api } return $response; } + + /** + * Get Case Notes + * + * @param string $app_uid {@min 1}{@max 32} + * @param string $start {@from path} + * @param string $limit {@from path} + * @param string $sort {@from path} + * @param string $dir {@from path} + * @param string $usr_uid {@from path} + * @param string $date_from {@from path} + * @param string $date_to {@from path} + * @param string $search {@from path} + * @return array + * + * @copyright Colosa - Bolivia + * + * @url GET /case/:app_uid/notes + */ + public function doGetCaseNotes( + $app_uid, + $start = 0, + $limit = 25, + $sort = 'APP_CACHE_VIEW.APP_NUMBER', + $dir = 'DESC', + $usr_uid = '', + $date_from = '', + $date_to = '', + $search = '' + ) { + try { + $dataList['start'] = $start; + $dataList['limit'] = $limit; + $dataList['sort'] = $sort; + $dataList['dir'] = $dir; + $dataList['user'] = $usr_uid; + $dataList['dateFrom'] = $date_from; + $dataList['dateTo'] = $date_to; + $dataList['search'] = $search; + + $usr_uid = $this->getUserId(); + $cases = new \ProcessMaker\BusinessModel\Cases(); + $response = $cases->getCaseNotes($app_uid, $usr_uid, $dataList); + $result = $this->parserDataNotes($response['data']); + return $result; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + public function parserDataNotes ($data) + { + $structure = array( + 'app_uid' => 'caseId', + 'usr_uid' => 'userId', + 'notes' => array( + 'note_date' => 'date', + 'note_content' => 'content' + ) + ); + + $response = $this->replaceFields($data, $structure); + return $response; + } + + /** + * Post Case Notes + * + * @param string $app_uid {@min 1}{@max 32} + * @param string $noteContent {@min 1}{@max 500} + * @param int $sendMail {@choice 1,0} + * + * @copyright Colosa - Bolivia + * + * @url POST /case/:app_uid/note + */ + public function doPostCaseNote($app_uid, $noteContent, $sendMail = 0) + { + try { + $usr_uid = $this->getUserId(); + $cases = new \ProcessMaker\BusinessModel\Cases(); + $sendMail = ($sendMail == 0) ? false : true; + $cases->saveCaseNote($app_uid, $usr_uid, $noteContent, $sendMail); + $result = array("status" => 'ok'); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + return $result; + } + + /** + * GET list category + * + * @return array + * @throws RestException + * + * @url GET /category + */ + public function getCategoryList() + { + try { + $oLight = new \ProcessMaker\BusinessModel\Light(); + $category = $oLight->getCategoryList(); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + return $category; + } + + /** + * GET list process + * + * @return array + * @throws RestException + * + * @param string $action {@min 1}{@max 32} + * @param string $cat_uid {@max 32}{@from path} + * + * @url GET /process/:action + */ + public function getProcessList ($action, $cat_uid = null) + { + try { + $usr_uid = $this->getUserId(); + $oLight = new \ProcessMaker\BusinessModel\Light(); + $process = $oLight->getProcessList($action, $cat_uid, $usr_uid); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + return $process; + } + + /** + * GET list process + * + * @return array + * @throws RestException + * + * @param string $task_uid {@min 1}{@max 32} + * + * @url GET /userstoreassign/:task_uid + */ + public function getUsersToReassign ($task_uid) + { + try { + $usr_uid = $this->getUserId(); + $oLight = new \ProcessMaker\BusinessModel\Light(); + $process = $oLight->getUsersToReassign($usr_uid, $task_uid); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + return $process; + } + + /** + * @return \stdclass + * @throws RestException + * + * @param string $app_uid {@min 1}{@max 32} + * @param string $to_usr_uid {@min 1}{@max 32} + * + * @url POST /reassign/:app_uid/user/:to_usr_uid + */ + public function reassignCase ($app_uid, $to_usr_uid) + { + try { + $usr_uid = $this->getUserId(); + $oLight = new \ProcessMaker\BusinessModel\Light(); + $process = $oLight->reassignCase($usr_uid, $app_uid, $to_usr_uid); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + return $process; + } + + /** + * Paused Case + * + * @return \stdclass + * @throws RestException + * + * @param string $app_uid {@min 1}{@max 32} + * + * @url POST /cases/:app_uid/pause + */ + public function pauseCase ($app_uid, $request_data) + { + try { + $usr_uid = $this->getUserId(); + $oLight = new \ProcessMaker\BusinessModel\Light(); + $process = $oLight->pauseCase($usr_uid, $app_uid, $request_data); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + return $process; + } + + /** + * Unpaused Case + * + * @return \stdclass + * @throws RestException + * + * @param string $app_uid {@min 1}{@max 32} + * + * @url POST /cases/:app_uid/unpause + */ + public function unpauseCase ($app_uid) + { + $result = array(); + try { + $usr_uid = $this->getUserId(); + $cases = new \ProcessMaker\BusinessModel\Cases(); + $cases->putUnpauseCase($app_uid, $usr_uid); + $result["status"] = "ok"; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + return $result; + } + + /** + * Cancel Case + * + * @param string $cas_uid {@min 1}{@max 32} + * + * @copyright Colosa - Bolivia + * + * @url POST /cases/:app_uid/cancel + */ + public function doPutCancelCase($app_uid) + { + $response = array("status" => "false"); + try { + $userUid = $this->getUserId(); + $cases = new \ProcessMaker\BusinessModel\Cases(); + $cases->putCancelCase($app_uid, $userUid); + $response["status"] = "ok"; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } + + /** + * @url GET /project/:prj_uid/case/:app_uid + * + * @param string $prj_uid {@min 32}{@max 32} + */ + public function doGetProcessMapImage($prj_uid, $app_uid) + { + $return = array(); + try { + $oPMap = new \ProcessMaker\BusinessModel\ProcessMap(); + $schema = Adapter\BpmnWorkflow::getStruct($prj_uid); + + $case = new \ProcessMaker\BusinessModel\Cases(); + $case->setFormatFieldNameInUppercase(false); + $schemaStatus = $case->getTasks($app_uid); + + $file = $oPMap->get_image($schema, $schemaStatus); + ob_start(); + imagepng($file); + $image = ob_get_clean(); + $return["map"] = base64_encode($image); + + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $return; + } } diff --git a/workflow/engine/templates/strategicDashboard/formDashboard.js b/workflow/engine/templates/strategicDashboard/formDashboard.js index ab4025611..46df67957 100644 --- a/workflow/engine/templates/strategicDashboard/formDashboard.js +++ b/workflow/engine/templates/strategicDashboard/formDashboard.js @@ -41,7 +41,6 @@ var frmDashboard; var addTabButton; var tabPanel; var dashboardIndicatorFields; -var dashboardIndicatorPanel; var store; var indexTab = 0; @@ -49,12 +48,11 @@ var comboPageSize = 10; var resultTpl; var storeIndicatorType; var storeGraphic; -var storeFrecuency; +var storeFrequency; var storeProject; var storeGroup; var storeUsers; var dataUserGroup; -var dasIndUid; var flag = true; var myMask; var dataIndicator = ''; @@ -63,13 +61,13 @@ var tabActivate = []; Ext.onReady( function() { myMask = new Ext.LoadMask(Ext.getBody(), {msg:_('ID_LOADING')}); - + Ext.QuickTips.init(); resultTpl = new Ext.XTemplate( '
', - ' {APP_PRO_TITLE}', + ' {APP_PRO_TITLE}', '
' ); @@ -79,21 +77,22 @@ Ext.onReady( function() { items : [ { id : 'DAS_TITLE', - fieldLabel : _('ID_DASHBOARD_TITLE'), + fieldLabel : ' * ' + _('ID_DASHBOARD_TITLE'), xtype : 'textfield', anchor : '85%', maxLength : 250, - maskRe : /([a-zA-Z0-9\s]+)$/, + maskRe : /([a-zA-Z0-9_'\s]+)$/, + regex : /([a-zA-Z0-9_'\s]+)$/, + regexText : _('ID_INVALID_VALUE', _('ID_DASHBOARD_TITLE')), allowBlank : false }, { xtype : 'textarea', id : 'DAS_DESCRIPTION', fieldLabel : _('ID_DESCRIPTION'), - labelSeparator : '', anchor : '85%', - maskRe : /([a-zA-Z0-9\s]+)$/, - height : 50, + maskRe : /([a-zA-Z0-9_'\s]+)$/, + height : 50 } ] }); @@ -238,7 +237,7 @@ Ext.onReady( function() { } }); - + storeIndicatorType = new Ext.data.GroupingStore( { proxy : new Ext.data.HttpProxy({ api: { @@ -295,7 +294,7 @@ Ext.onReady( function() { } }); - storeFrecuency = new Ext.data.GroupingStore( { + storeFrequency = new Ext.data.GroupingStore( { proxy : new Ext.data.HttpProxy({ api: { read : urlProxy + 'catalog/periodicity' @@ -448,7 +447,7 @@ Ext.onReady( function() { return '
' + '

{owner_uid}{owner_label}

' + '{excerpt}' + - '
'; + ''; } }, //pageSize : 10, @@ -485,7 +484,7 @@ Ext.onReady( function() { } }, { - title: _('ID_PRO_USER'), + title: _('ID_PRO_USER') }, ownerInfoGrid ] @@ -494,7 +493,7 @@ Ext.onReady( function() { addTabButton = new Ext.Button ({ text: _('ID_NEW_TAB_INDICATOR'), iconCls: 'button_menu_ext ss_sprite ss_add', - handler: addTab, + handler: addTab }); tabPanel = new Ext.TabPanel({ @@ -528,23 +527,24 @@ Ext.onReady( function() { flag = true; break; case 'yes': + tabPanel.getItem(component.id).show(); flag = false; var dasIndUid = Ext.getCmp('DAS_IND_UID_'+component.id).getValue(); if (typeof dasIndUid != 'undefined' && dasIndUid != '') { removeIndicator(dasIndUid); } tabActivate.remove(component.id); - tabPanel.remove(component); + tabPanel.remove(component, true); break; } }, scope: that }); - return false; + return false; } else { flag = true; } - + }, tabchange : function ( that, tab ) { var id = tabPanel.getActiveTab().id; @@ -626,12 +626,9 @@ Ext.onReady( function() { items : [ addTabButton, tabPanel - ] }); - - //form frmDashboard = new Ext.FormPanel({ id : 'frmDashboard', @@ -644,11 +641,11 @@ Ext.onReady( function() { waitMsgTarget : true, frame : true, defaults : { - anchor : '100%', - allowBlank : false, - resizable : true, - msgTarget : 'side', - align : 'center' + anchor : '100%', + allowBlank : false, + resizable : true, + msgTarget : 'side', + align : 'center' }, items : [ dashboardFields, @@ -671,10 +668,9 @@ Ext.onReady( function() { ] }); - ownerInfoGrid.store.load(); ownerInfoGrid.on("afterrender", function(component) { component.getBottomToolbar().refresh.hideParent = true; - component.getBottomToolbar().refresh.hide(); + component.getBottomToolbar().refresh.hide(); }); viewport = new Ext.Viewport({ @@ -698,6 +694,7 @@ Ext.onReady( function() { } dashboardOwnerFields.items.items[0].bindStore(dataUserGroup); } ); + storeUsers.on( 'load', function( store, records, options ) { for (var i=0; i< store.data.length; i++) { row = []; @@ -730,243 +727,245 @@ var addTab = function (flag) { return false; } var tab = { - title : _('ID_INDICATOR')+ ' '+ (++indexTab), - id : indexTab, - iconCls : 'tabs', - width : "100%", - items : [ - new Ext.Panel({ - height : 230, - width : "100%", - border : true, - bodyStyle : 'padding:10px', - items : [ - new Ext.form.FieldSet({ - labelWidth : 150, - labelAlign :'right', - items : [ - { - id : 'DAS_IND_UID_' + indexTab, - xtype : 'textfield', - hidden : true - }, - { - fieldLabel : _('ID_INDICATOR_TITLE'), - id : 'IND_TITLE_'+ indexTab, - xtype : 'textfield', - anchor : '85%', - maskRe : /([a-zA-Z0-9\s]+)$/, - maxLength : 250, - allowBlank : false - }, - new Ext.form.ComboBox({ - anchor : '85%', - editable : false, - id : 'IND_TYPE_'+ indexTab, - fieldLabel : _('ID_INDICATOR_TYPE'), - displayField : 'CAT_LABEL_ID', - valueField : 'CAT_UID', - forceSelection : false, - emptyText : _('ID_SELECT'), - selectOnFocus : true, - typeAhead : true, - autocomplete : true, - triggerAction : 'all', - store : storeIndicatorType, - listeners:{ - scope: this, - select: function(combo, record, index) { - var value = combo.getValue(); - var field = ''; - var index = tabPanel.getActiveTab().id; - var fields = ['DAS_IND_FIRST_FIGURE_'+index,'DAS_IND_FIRST_FREQUENCY_'+index,'DAS_IND_SECOND_FIGURE_'+index, 'DAS_IND_SECOND_FREQUENCY_'+index]; - if (value == '1050') { - field = Ext.getCmp('IND_PROCESS_'+index); + title : _('ID_INDICATOR')+ ' '+ (++indexTab), + id : indexTab, + iconCls : 'tabs', + width : "100%", + items : [ + new Ext.Panel({ + height : 230, + width : "100%", + border : true, + bodyStyle : 'padding:10px', + items : [ + new Ext.form.FieldSet({ + labelWidth : 150, + labelAlign :'right', + items : [ + { + id : 'DAS_IND_UID_' + indexTab, + xtype : 'textfield', + hidden : true + }, + { + fieldLabel : ' * ' + _('ID_INDICATOR_TITLE'), + id : 'IND_TITLE_'+ indexTab, + xtype : 'textfield', + anchor : '85%', + maskRe : /([a-zA-Z0-9_'\s]+)$/, + regex : /([a-zA-Z0-9_'\s]+)$/, + regexText : _('ID_INVALID_VALUE', _('ID_INDICATOR_TITLE')), + maxLength : 250, + allowBlank : false + }, + new Ext.form.ComboBox({ + anchor : '85%', + editable : false, + id : 'IND_TYPE_'+ indexTab, + fieldLabel : ' * ' + _('ID_INDICATOR_TYPE'), + displayField : 'CAT_LABEL_ID', + valueField : 'CAT_UID', + forceSelection : false, + emptyText : _('ID_SELECT'), + selectOnFocus : true, + typeAhead : true, + autocomplete : true, + triggerAction : 'all', + store : storeIndicatorType, + listeners:{ + scope: this, + select: function(combo, record, index) { + var value = combo.getValue(); + var field = ''; + var index = tabPanel.getActiveTab().id; + var fields = ['DAS_IND_FIRST_FIGURE_'+index,'DAS_IND_FIRST_FREQUENCY_'+index,'DAS_IND_SECOND_FIGURE_'+index, 'DAS_IND_SECOND_FREQUENCY_'+index]; + if (value == '1050') { + field = Ext.getCmp('IND_PROCESS_'+index); + field.setValue('0'); + field.disable(); + field.hide(); + } else { + field = Ext.getCmp('IND_PROCESS_'+index); + field.enable(); + field.show(); + } + if (value == '1010' || value == '1030' || value == '1050') { + for (var i=0; i