diff --git a/gulliver/js/pmchart/pmCharts.js b/gulliver/js/pmchart/pmCharts.js index 6fcba252a..434174dfc 100644 --- a/gulliver/js/pmchart/pmCharts.js +++ b/gulliver/js/pmchart/pmCharts.js @@ -109,6 +109,7 @@ BarChart.prototype.drawBars = function(data, canvas, param) { var currObj = this; if (data == null || data.length == 0) { + console.log(graphDim); canvas.append("text") .attr('class','pm-charts-no-draw') .attr("y", graphDim.height/2) @@ -1385,6 +1386,7 @@ PieChart.prototype.drawPie2D = function (dataset, canvas, param) { .enter() .append("text") .attr("x", width + 30) + .attr("class", "legend") .text(function (d, i) { return (d.datalabel + "-" + getPercent(d.value)) }) diff --git a/gulliver/system/class.publisher.php b/gulliver/system/class.publisher.php index 40b7fc20e..e398cba52 100755 --- a/gulliver/system/class.publisher.php +++ b/gulliver/system/class.publisher.php @@ -294,10 +294,10 @@ class Publisher //This dynaform has show/hide field conditions if (isset($_SESSION['CURRENT_DYN_UID']) && $_SESSION['CURRENT_DYN_UID'] != '') { - $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CURRENT_DYN_UID"]); //lsl + $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CURRENT_DYN_UID"]); } else { if (isset($_SESSION['CONDITION_DYN_UID']) && $_SESSION['CONDITION_DYN_UID'] != '') { - $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CONDITION_DYN_UID"]); //lsl + $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CONDITION_DYN_UID"]); } } } @@ -649,4 +649,3 @@ class Publisher $G_TABLE = null; } } - diff --git a/workflow/engine/classes/class.calendar.php b/workflow/engine/classes/class.calendar.php index 7ec30c177..48f50b77f 100755 --- a/workflow/engine/classes/class.calendar.php +++ b/workflow/engine/classes/class.calendar.php @@ -414,7 +414,7 @@ class calendar extends CalendarDefinition $hoursDuration -= (float)($secondRes/3600); //$dataLog[] = (float)($secondRes/3600); } else { - $newDate = date('Y-m-d H:i:s', strtotime('+' . (((float)$hoursDuration)*3600) . ' seconds', strtotime($newDate))); + $newDate = date("Y-m-d H:i:s", strtotime("+" . round(((float)($hoursDuration)) * 3600) . " seconds", strtotime($newDate))); //$dataLog[] = (float)($hoursDuration); $hoursDuration = 0; } diff --git a/workflow/engine/classes/class.indicatorsCalculator.php b/workflow/engine/classes/class.indicatorsCalculator.php index c4fa95bd1..321e1857e 100644 --- a/workflow/engine/classes/class.indicatorsCalculator.php +++ b/workflow/engine/classes/class.indicatorsCalculator.php @@ -337,6 +337,36 @@ class indicatorsCalculator return $retval; } + public function ueiCostHistoric($employeeId, $initDate, $endDate, $periodicity) + { + if (!is_a($initDate, 'DateTime')) throw new InvalidArgumentException ('initDate parameter must be a DateTime object.', 0); + if (!is_a($endDate, 'DateTime')) throw new InvalidArgumentException ('endDate parameter must be a DateTime object.', 0); + + $periodicitySelectFields = $this->periodicityFieldsForSelect($periodicity); + $periodicityGroup = $this->periodicityFieldsForGrouping($periodicity); + $initYear = $initDate->format("Y"); + $initMonth = $initDate->format("m"); + $initDay = $endDay = 1; + $endYear = $endDate->format("Y"); + $endMonth = $endDate->format("m"); + + //$params[":initYear"] = $initYear; + //$params[":initMonth"] = $initMonth; + $params[":endYear"] = $endYear; + $params[":endMonth"] = $endMonth; + + + $sqlString = "SELECT $periodicitySelectFields " . $this->ueiCostFormula . " as EEC + FROM USR_REPORTING + WHERE + IF(`YEAR` = :endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = :endYear, :endMonth, :endYear)" + . $periodicityGroup; + + $retval = $this->pdoExecutor($sqlString, $params); + //$retval = $this->propelExecutor($sqlString); + return $retval; + } + public function generalIndicatorData($indicatorId, $initDate, $endDate, $periodicity) { if (!is_a($initDate, 'DateTime')) throw new InvalidArgumentException ('initDate parameter must be a DateTime object.', 0); if (!is_a($endDate, 'DateTime')) throw new InvalidArgumentException ('endDate parameter must be a DateTime object.', 0); @@ -443,14 +473,16 @@ class indicatorsCalculator $sqlString = " select i.TAS_UID as uid, t.CON_VALUE as name, - i.efficienceIndex, + i.efficiencyIndex, + i.inefficiencyCost, i.averageTime, i.deviationTime, i.configuredTime FROM ( select TAS_UID, - $this->peiFormula as efficienceIndex, + $this->peiFormula as efficiencyIndex, + $this->peiCostFormula as inefficiencyCost, AVG(AVG_TIME) as averageTime, AVG(SDV_TIME) as deviationTime, CONFIGURED_TASK_TIME as configuredTime @@ -468,6 +500,95 @@ class indicatorsCalculator return $retval; } + public function statusIndicatorGeneral ($usrUid) + { + $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 + FROM LIST_INBOX + WHERE USR_UID = :usrUid + AND APP_STATUS = 'TO_DO' + AND DEL_DUE_DATE IS NOT NULL "; + + return $this->pdoExecutor($sqlString, $params); + } + + public function statusIndicatorDetail ($usrUid) + { + $params[':usrUid'] = $usrUid; + + $sqlString = "SELECT + TAS_UID as tasUid, + PRO_UID as proUid, + 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 + FROM LIST_INBOX + WHERE USR_UID = :usrUid + AND APP_STATUS = 'TO_DO' + AND DEL_DUE_DATE IS NOT NULL + GROUP BY TAS_UID"; + + return $this->pdoExecutor($sqlString, $params); + } + + public function statusIndicator($usrUid) + { + $response = array(); + $result = $this->statusIndicatorGeneral($usrUid); + + $response['overdue'] = 0; + $response['atRisk'] = 0; + $response['onTime'] = 0; + $response['percentageOverdue'] = 0; + $response['percentageAtRisk'] = 0; + $response['percentageOnTime'] = 0; + $response['dataList'] = array(); + + if (is_array($result) && isset($result[0])) { + $response['overdue'] = $result[0]['OVERDUE']; + $response['atRisk'] = $result[0]['ONTIME']; + $response['onTime'] = $result[0]['ATRISK']; + + $total = $response['overdue'] + $response['atRisk'] + $response['onTime']; + if ($total != 0) { + $response['percentageOverdue'] = ($response['overdue']*100)/$total; + $response['percentageAtRisk'] = ($response['atRisk']*100)/$total; + $response['percentageOnTime'] = ($response['onTime']*100)/$total; + } + } + + $result = $this->statusIndicatorDetail($usrUid); + + foreach ($result as $key => $value) { + $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; + $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; + } + } + $response['dataList'] = $result; + return $response; + } private function periodicityFieldsForSelect($periodicity) { $periodicityFields = $this->periodicityFieldsString($periodicity); diff --git a/workflow/engine/classes/class.licensedFeatures.php b/workflow/engine/classes/class.licensedFeatures.php index f2aef8649..dcf2161bb 100644 --- a/workflow/engine/classes/class.licensedFeatures.php +++ b/workflow/engine/classes/class.licensedFeatures.php @@ -27,6 +27,127 @@ class PMLicensedFeatures { private $featuresDetails = array (); private $features = array (); + private $newFeatures = array( + 0 => array( + "description" => "Enables de Actions By Email feature.", + "enabled" => false, + "id" => "actionsByEmail", + "latest_version" => "", + "log" => null, + "name" => "actionsByEmail", + "nick" => "actionsByEmail", + "progress" => 0, + "publisher" => "Colosa", + "release_type" => "localRegistry", + "status" => "ready", + "store" => "00000000000000000000000000010004", + "type" => "features", + "url" => "", + "version" => "" + ), + 1 => array( + "description" => "Enables de Batch Routing feature.", + "enabled" => false, + "id" => "pmConsolidatedCL", + "latest_version" => "", + "log" => null, + "name" => "pmConsolidatedCL", + "nick" => "pmConsolidatedCL", + "progress" => 0, + "publisher" => "Colosa", + "release_type" => "localRegistry", + "status" => "ready", + "store" => "00000000000000000000000000010005", + "type" => "features", + "url" => "", + "version" => "" + ), + 2 => array( + "description" => "Dashboard with improved charting graphics and optimized to show strategic information like Process Efficiency and User Efficiency indicators.", + "enabled" => false, + "id" => "strategicDashboards", + "latest_version" => "", + "log" => null, + "name" => "strategicDashboards", + "nick" => "Strategic Dashboards", + "progress" => 0, + "publisher" => "Colosa", + "release_type" => "localRegistry", + "status" => "ready", + "store" => "00000000000000000000000000010006", + "type" => "features", + "url" => "", + "version" => "" + ), + 3 => array( + "description" => "Enables the configuration of a second database connection in order to divide the database requests in read and write operations. This features is used with database clusters to improve the application performance.", + "enabled" => false, + "id" => "secondDatabaseConnection", + "latest_version" => "", + "log" => null, + "name" => "secondDatabaseConnection", + "nick" => "secondDatabaseConnection", + "progress" => 0, + "publisher" => "Colosa", + "release_type" => "localRegistry", + "status" => "ready", + "store" => "00000000000000000000000000010000", + "type" => "features", + "url" => "", + "version" => "" + ), + 4 => array( + "description" => "Registers every admin action in a log. The actions in administration settings options are registered in the log.", + "enabled" => false, + "id" => "auditLog", + "latest_version" => "", + "log" => null, + "name" => "auditLog", + "nick" => "auditLog", + "progress" => 0, + "publisher" => "Colosa", + "release_type" => "localRegistry", + "status" => "ready", + "store" => "00000000000000000000000000010001", + "type" => "features", + "url" => "", + "version" => "" + ), + 5 => array( + "description" => "A more secure option to store user passwords in ProcessMaker. The modern algorithm SHA-2 is used to store the passwords.", + "enabled" => false, + "id" => "secureUserPasswordHash", + "latest_version" => "", + "log" => null, + "name" => "secureUserPasswordHash", + "nick" => "secureUserPasswordHash", + "progress" => 0, + "publisher" => "Colosa", + "release_type" => "localRegistry", + "status" => "ready", + "store" => "00000000000000000000000000010002", + "type" => "features", + "url" => "", + "version" => "" + ), + 6 => array( + "description" => "This functionality enables the flexibility to send mails from different email servers or configurations.", + "enabled" => false, + "id" => "sendEmailFromDifferentEmailServers", + "latest_version" => "", + "log" => null, + "name" => "sendEmailFromDifferentEmailServers", + "nick" => "sendEmailFromDifferentEmailServers", + "progress" => 0, + "publisher" => "Colosa", + "release_type" => "localRegistry", + "status" => "ready", + "store" => "00000000000000000000000000010003", + "type" => "features", + "url" => "", + "version" => "" + ) + ); private static $instancefeature = null; @@ -87,6 +208,132 @@ class PMLicensedFeatures $this->featuresDetails[$value[0]]->enabled = $enable; return $enable; } + + public function addNewFeatures ($data) + { + $newFeaturesList = $this->newFeatures; + $newData = array(); + $newFeaturesIds = array(); + foreach($newFeaturesList as $val) { + $newFeaturesIds[] = $val['id']; + } + $criteria = new Criteria(); + $criteria->addSelectColumn(AddonsManagerPeer::ADDON_ID); + $criteria->add(AddonsManagerPeer::ADDON_ID, $newFeaturesIds, Criteria::IN); + $criteria->add(AddonsManagerPeer::ADDON_TYPE, 'features'); + $rs = AddonsManagerPeer::doSelectRS($criteria); + $rs->next(); + $row = $rs->getRow(); + if(sizeof($row)) { + while (is_array($row)) { + $ids[] = $row[0]; + $rs->next(); + $row = $rs->getRow(); + } + $toUpdate = array_diff($newFeaturesIds,$ids); + + if(sizeof($toUpdate)){ + $newFeaturesListAux = array(); + foreach($toUpdate as $index => $v) { + $newFeaturesListAux[] = $newFeaturesList[$index]; + } + unset($newFeaturesList); + $newFeaturesList = array_values($newFeaturesListAux); + } else { + return $data; + } + } + + foreach($newFeaturesList as $k => $newFeature){ + $newData[] = array ( + 'db' => 'wf', + 'table' => 'ADDONS_MANAGER', + 'keys' => + array ( + 0 => 'ADDON_ID', + ), + 'data' => + array ( + 0 => + array ( + 'field' => 'ADDON_DESCRIPTION', + 'type' => 'text', + 'value' => $newFeature['description'], + ), + 1 => + array ( + 'field' => 'ADDON_ID', + 'type' => 'text', + 'value' => $newFeature['id'], + ), + 2 => + array ( + 'field' => 'ADDON_NAME', + 'type' => 'text', + 'value' => $newFeature['name'], + ), + 3 => + array ( + 'field' => 'ADDON_NICK', + 'type' => 'text', + 'value' => $newFeature['nick'], + ), + 4 => + array ( + 'field' => 'ADDON_PUBLISHER', + 'type' => 'text', + 'value' => $newFeature['publisher'], + ), + 5 => + array ( + 'field' => 'ADDON_RELEASE_TYPE', + 'type' => 'text', + 'value' => $newFeature['release_type'], + ), + 6 => + array ( + 'field' => 'ADDON_STATUS', + 'type' => 'text', + 'value' => $newFeature['status'], + ), + 7 => + array ( + 'field' => 'STORE_ID', + 'type' => 'text', + 'value' => $newFeature['store'], + ), + 8 => + array ( + 'field' => 'ADDON_TYPE', + 'type' => 'text', + 'value' => $newFeature['type'], + ), + 9 => + array ( + 'field' => 'ADDON_DOWNLOAD_URL', + 'type' => 'text', + 'value' => $newFeature['url'], + ), + 10 => + array ( + 'field' => 'ADDON_VERSION', + 'type' => 'text', + 'value' => $newFeature['version'], + ), + 11 => + array ( + 'field' => 'ADDON_DOWNLOAD_PROGRESS', + 'type' => 'text', + 'value' => $newFeature['progress'], + ) + ), + 'action' => 1, + ); + + $i++; + } + return array_merge($data, $newData); + } /*----------------------------------********---------------------------------*/ } diff --git a/workflow/engine/classes/class.pmDynaform.php b/workflow/engine/classes/class.pmDynaform.php index 52d6fa84c..cb703e3ff 100644 --- a/workflow/engine/classes/class.pmDynaform.php +++ b/workflow/engine/classes/class.pmDynaform.php @@ -3,7 +3,7 @@ /** * class.pmDynaform.php * Implementing pmDynaform library in the running case. - * + * * @author Roly Rudy Gutierrez Pinto * @package engine.classes */ @@ -80,19 +80,37 @@ class pmDynaform public function jsonr(&$json) { - foreach ($json as $key => $value) { + foreach ($json as $key => &$value) { $sw1 = is_array($value); $sw2 = is_object($value); if ($sw1 || $sw2) { $this->jsonr($value); } if (!$sw1 && !$sw2) { - //property + //set properties from trigger $prefixs = array("@@", "@#", "@%", "@?", "@$", "@="); if (is_string($value) && in_array(substr($value, 0, 2), $prefixs)) { $triggerValue = substr($value, 2); if (isset($this->fields["APP_DATA"][$triggerValue])) { - $json->$key = $this->fields["APP_DATA"][$triggerValue]; + $json->{$key} = $this->fields["APP_DATA"][$triggerValue]; + } + } + //set properties from 'formInstance' variable + if (isset($this->fields["APP_DATA"]["formInstance"])) { + $formInstance = $this->fields["APP_DATA"]["formInstance"]; + if (!is_array($formInstance)) { + $formInstance = array($formInstance); + } + $nfi = count($formInstance); + for ($ifi = 0; $ifi < $nfi; $ifi++) { + $fi = $formInstance[$ifi]; + if (is_object($fi) && isset($fi->id) && $key === "id" && $json->{$key} === $fi->id) { + foreach ($fi as $keyfi => $valuefi) { + if (isset($json->{$keyfi})) { + $json->{$keyfi} = $valuefi; + } + } + } } } //query & options @@ -136,11 +154,17 @@ class pmDynaform array_push($json->options, $option); } } catch (Exception $e) { - + } } if (isset($json->options[0])) { $json->data = $json->options[0]; + $no = count($json->options); + for ($io = 0; $io < $no; $io++) { + if ($json->options[$io]["value"] === $json->defaultValue) { + $json->data = $json->options[$io]; + } + } } } //data @@ -187,7 +211,7 @@ class pmDynaform if ($column->type === "text" || $column->type === "textarea" || $column->type === "dropdown" || $column->type === "datetime" || $column->type === "checkbox" || $column->type === "file" || $column->type === "link") { array_push($cells, array( "value" => isset($row[$column->name]) ? $row[$column->name] : "", - "label" => isset($row[$column->name . "_label"]) ? $row[$column->name . "_label"] : "" + "label" => isset($row[$column->name . "_label"]) ? $row[$column->name . "_label"] : (isset($row[$column->name]) ? $row[$column->name] : "") )); } if ($column->type === "suggest") { @@ -208,11 +232,15 @@ class pmDynaform $this->lang = $json->language; } if ($this->langs !== null) { - if (($key === "label" || $key === "hint" || $key === "placeholder" || $key === "validateMessage" || $key === "alternateText" || $key === "comment" || $key === "alt") && isset($json->{$key}) && isset($this->langs->{$this->lang})) { + if (($key === "label" || $key === "title" || $key === "hint" || $key === "placeholder" || $key === "validateMessage" || $key === "alternateText" || $key === "comment" || $key === "alt") && isset($this->langs->{$this->lang})) { $langs = $this->langs->{$this->lang}->Labels; foreach ($langs as $langsValue) { - if ($json->{$key} === $langsValue->msgid) + if (is_object($json) && $json->{$key} === $langsValue->msgid) { $json->{$key} = $langsValue->msgstr; + } + if (is_array($json) && $json[$key] === $langsValue->msgid) { + $json[$key] = $langsValue->msgstr; + } } } } @@ -225,6 +253,72 @@ class pmDynaform return $this->record != null && $this->record["DYN_VERSION"] == 2 ? true : false; } + public function printViewWithoutSubmit() + { + ob_clean(); + + $json = G::json_decode($this->record["DYN_CONTENT"]); + + foreach ($json->items[0]->items as $key => $value) { + switch ($json->items[0]->items[$key][0]->type) { + case "submit": + unset($json->items[0]->items[$key]); + break; + } + } + + $this->jsonr($json); + + $javascript = " + + +
+
< " . G::LoadTranslation("ID_BACK") . "
+
+
+ "; + + $file = file_get_contents(PATH_HOME . "public_html" . PATH_SEP . "lib" . PATH_SEP . "pmdynaform" . PATH_SEP . "build" . PATH_SEP . "pmdynaform.html"); + $file = str_replace("{javascript}", $javascript, $file); + + echo $file; + exit(0); + } + public function printView() { ob_clean(); @@ -409,6 +503,8 @@ class pmDynaform $json->name = $newVariable["VAR_NAME"]; if (isset($json->dbConnection) && $json->dbConnection === $oldVariable["VAR_DBCONNECTION"]) $json->dbConnection = $newVariable["VAR_DBCONNECTION"]; + if (isset($json->dbConnectionLabel) && $json->dbConnectionLabel === $oldVariable["VAR_DBCONNECTION_LABEL"]) + $json->dbConnectionLabel = $newVariable["VAR_DBCONNECTION_LABEL"]; if (isset($json->sql) && $json->sql === $oldVariable["VAR_SQL"]) $json->sql = $newVariable["VAR_SQL"]; if (isset($json->options) && G::json_encode($json->options) === $oldVariable["VAR_ACCEPTED_VALUES"]) { diff --git a/workflow/engine/classes/class.processMap.php b/workflow/engine/classes/class.processMap.php index 3d65399c7..7dd4742f1 100755 --- a/workflow/engine/classes/class.processMap.php +++ b/workflow/engine/classes/class.processMap.php @@ -1588,8 +1588,9 @@ class processMap $numRows = DynaformPeer::doCount($oCriteria); if ($numRows == 0) { - echo "
".G::LoadTranslation('ID_ALERT')."
".G::LoadTranslation('ID_CONSOLIDATED_DYNAFORM_REQUIRED')."
"; - die; + $aFields['TITLE_ALERT'] = G::LoadTranslation('ID_ALERT'); + $aFields['SUBTITLE_MESSAGE'] = G::LoadTranslation('ID_CONSOLIDATED_DYNAFORM_REQUIRED'); + $sFilename = 'tasks/tasks_Consolidated_Error.xml'; } } diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index cea83655a..6483a4afb 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -919,6 +919,10 @@ class workspaceTools if (file_exists(PATH_CORE . 'data' . PATH_SEP . 'check.data')) { $checkData = unserialize(file_get_contents(PATH_CORE . 'data' . PATH_SEP . 'check.data')); if (is_array($checkData)) { + /*----------------------------------********---------------------------------*/ + $licensedFeatures = & PMLicensedFeatures::getSingleton(); + $checkData = $licensedFeatures->addNewFeatures($checkData); + /*----------------------------------********---------------------------------*/ foreach ($checkData as $checkThis) { $this->updateThisRegistry($checkThis); } diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php index caf32c9cc..388d48542 100755 --- a/workflow/engine/classes/model/AppDelegation.php +++ b/workflow/engine/classes/model/AppDelegation.php @@ -356,17 +356,18 @@ class AppDelegation extends BaseAppDelegation $aCalendarUID = ''; } - //use the dates class to calculate dates + //Calendar - Use the dates class to calculate dates $calendar = new calendar(); $arrayCalendarData = array(); if ($calendar->pmCalendarUid == "") { - $calendar->getCalendar(null, $task->getProUid(), $this->getTasUid()); + $calendar->getCalendar(null, $this->getProUid(), $this->getTasUid()); $arrayCalendarData = $calendar->getCalendarData(); } + //Due date /*$iDueDate = $calendar->calculateDate( $this->getDelDelegateDate(), $aData['TAS_DURATION'], $aData['TAS_TIMEUNIT'] //hours or days, ( we only accept this two types or maybe weeks );*/ $dueDate = $calendar->dashCalculateDate($this->getDelDelegateDate(), $aData["TAS_DURATION"], $aData["TAS_TIMEUNIT"], $arrayCalendarData); @@ -378,10 +379,22 @@ class AppDelegation extends BaseAppDelegation public function calculateRiskDate($dueDate, $risk) { try { - $numDueDate = strtotime($dueDate); //Seconds - $numDueDate = $numDueDate - ($numDueDate * $risk); + $riskTime = strtotime($dueDate) - strtotime($this->getDelDelegateDate()); //Seconds + $riskTime = $riskTime - ($riskTime * $risk); - $riskDate = date("Y-m-d H:i:s", round($numDueDate)); + //Calendar - Use the dates class to calculate dates + $calendar = new calendar(); + + $arrayCalendarData = array(); + + if ($calendar->pmCalendarUid == "") { + $calendar->getCalendar(null, $this->getProUid(), $this->getTasUid()); + + $arrayCalendarData = $calendar->getCalendarData(); + } + + //Risk date + $riskDate = $calendar->dashCalculateDate($this->getDelDelegateDate(), round($riskTime / (60 * 60)), "HOURS", $arrayCalendarData); //Return return $riskDate; diff --git a/workflow/engine/classes/model/DashboardIndicator.php b/workflow/engine/classes/model/DashboardIndicator.php index 6a4bdc47f..c33abdf7c 100644 --- a/workflow/engine/classes/model/DashboardIndicator.php +++ b/workflow/engine/classes/model/DashboardIndicator.php @@ -70,6 +70,28 @@ class DashboardIndicator extends BaseDashboardIndicator $oldValue = current(reset($calculator->ueiHistoric($uid, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE))); $row['DAS_IND_VARIATION'] = $value - $oldValue; break; + case '1050': + $value = $calculator->statusIndicatorGeneral($userUid); + $row['OVERDUE'] = 0; + $row['ON_TIME'] = 0; + $row['AT_RISK'] = 0; + $row['PERCENTAGE_OVERDUE'] = 0; + $row['PERCENTAGE_AT_RISK'] = 0; + $row['PERCENTAGE_ON_TIME'] = 0; + + if (is_array($value) && isset($value[0])) { + $row['OVERDUE'] = $value[0]['OVERDUE']; + $row['ON_TIME'] = $value[0]['ONTIME']; + $row['AT_RISK'] = $value[0]['ATRISK']; + + $total = $row['OVERDUE'] + $row['AT_RISK'] + $row['ON_TIME']; + if ($total != 0) { + $row['PERCENTAGE_OVERDUE'] = ($row['OVERDUE']*100)/$total; + $row['PERCENTAGE_AT_RISK'] = ($row['AT_RISK']*100)/$total; + $row['PERCENTAGE_ON_TIME'] = ($row['ON_TIME']*100)/$total; + } + } + break; default: $arrResult = $calculator->generalIndicatorData($row['DAS_IND_UID'], $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE); $value = $arrResult[0]['value']; diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql old mode 100755 new mode 100644 index 4a9996c20..558cb0df4 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -59976,8 +59976,13 @@ INSERT INTO CATALOG (CAT_UID, CAT_LABEL_ID, CAT_TYPE, CAT_FLAG, CAT_OBSERVATION, ('400','ID_YEAR','PERIODICITY','','','2015-03-04','2015-03-04'), ('1010','ID_PROCESS_EFFICIENCE','INDICATOR','','','2015-03-04','2015-03-04'), ('1030','ID_EMPLYEE_EFFICIENCIE','INDICATOR','','','2015-03-04','2015-03-04'), -('1040','ID_USER_INEFFICIENCE','INDICATOR','','','2015-03-04','2015-03-04'), ('1050','ID_OVER_DUE','INDICATOR','%','Unit for displaying','2015-03-04','2015-03-04'), -('1060','ID_NEW_CASES','INDICATOR','','','2015-03-04','2015-03-04'), -('1070','ID_COMPLETED_CASES','INDICATOR','','','2015-03-04','2015-03-04'), -('1080','ID_WORKING_CASES','INDICATOR','','','2015-03-04','2015-03-04'); + +INSERT INTO ADDONS_MANAGER (ADDON_DESCRIPTION,ADDON_ID,ADDON_NAME,ADDON_NICK,ADDON_PUBLISHER,ADDON_RELEASE_TYPE,ADDON_STATUS,STORE_ID,ADDON_TYPE,ADDON_DOWNLOAD_URL,ADDON_VERSION,ADDON_DOWNLOAD_PROGRESS) VALUES +('Enables de Actions By Email feature.','actionsByEmail','actionsByEmail','actionsByEmail','Colosa','localRegistry','ready','00000000000000000000000000010004','features','','','0'), +('Enables de Batch Routing feature.','pmConsolidatedCL','pmConsolidatedCL','pmConsolidatedCL','Colosa','localRegistry','ready','00000000000000000000000000010005','features','','','0'), +('Dashboard with improved charting graphics and optimized to show strategic information like Process Efficiency and User Efficiency indicators.','strategicDashboards','strategicDashboards','Strategic Dashboards','Colosa','localRegistry','ready','00000000000000000000000000010006','features','','','0'), +('Enables the configuration of a second database connection in order to divide the database requests in read and write operations. This features is used with database clusters to improve the application performance.','secondDatabaseConnection','secondDatabaseConnection','secondDatabaseConnection','Colosa','localRegistry','ready','00000000000000000000000000010000','features','','','0'), +('A more secure option to store user passwords in ProcessMaker. The modern algorithm SHA-2 is used to store the passwords.','secureUserPasswordHash','secureUserPasswordHash','secureUserPasswordHash','Colosa','localRegistry','ready','00000000000000000000000000010002','features','','','0'), +('This functionality enables the flexibility to send mails from different email servers or configurations.','sendEmailFromDifferentEmailServers','sendEmailFromDifferentEmailServers','sendEmailFromDifferentEmailServers','Colosa','localRegistry','ready','00000000000000000000000000010003','features','','','0'), +('Registers every admin action in a log. The actions in administration settings options are registered in the log.','auditLog','auditLog','auditLog','Colosa','localRegistry','ready','00000000000000000000000000010001','features','','','0'); diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index ee3fbb175..ea632a452 100755 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -2789,7 +2789,7 @@ CREATE TABLE `DASHBOARD_DAS_IND` ( `DAS_UID` VARCHAR(32) default '' NOT NULL, `OWNER_UID` VARCHAR(32) default '' NOT NULL, - `OWNER_TYPE` VARCHAR(15) default '' NOT NULL + `OWNER_TYPE` VARCHAR(15) default '' NOT NULL, PRIMARY KEY (`DAS_UID`), CONSTRAINT `fk_dashboard_indicator_dashboard_das_ind` FOREIGN KEY (`DAS_UID`) diff --git a/workflow/engine/js/strategicDashboard/dashboard.js b/workflow/engine/js/strategicDashboard/dashboard.js deleted file mode 100644 index bc177d283..000000000 --- a/workflow/engine/js/strategicDashboard/dashboard.js +++ /dev/null @@ -1,1237 +0,0 @@ - var peiParams = { - canvas : { - containerId:'proEfficGenGraph', - width:300, - height:300, - stretch:true - }, - graph: { - allowDrillDown:false, - allowTransition:true, - showTip: true, - allowZoom: true, //verificar navegadores... - gapWidth:0.2, - useShadows: true, //for Firefox and Chrome - thickness: 30, - showLabels: true, - colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a'] - } - }; - - var ueiParams = { - canvas : { - containerId:'proEfficGenGraph', - width:300, - height:300, - stretch:true - }, - graph: { - allowTransition: false, - allowDrillDown: true, - showTip: true, - allowZoom: false, - useShadows: false, - gridLinesX: true, - gridLinesY: true, - area: {visible: false, css:"area"}, - axisX:{ showAxis: true, label: G_STRING.ID_GROUPS }, - axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS }, - showErrorBars: true - } - }; - - - var generalLineParams1 = { - canvas : { - containerId:'generalGraph1', - width:300, - height:300, - stretch:true - }, - graph: { - allowTransition: false, - allowDrillDown: true, - showTip: true, - allowZoom: false, - useShadows: false, - gridLinesX: true, - gridLinesY: true, - area: {visible: false, css:"area"}, - axisX:{ showAxis: true, label: G_STRING.ID_PROCESS_TASKS }, - axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS }, - showErrorBars: false - } - }; - - var generalLineParams2 = { - canvas : { - containerId:'generalGraph2', - width:300, - height:300, - stretch:true - }, - graph: { - allowTransition: false, - allowDrillDown: true, - showTip: true, - allowZoom: false, - useShadows: false, - gridLinesX: true, - gridLinesY: true, - area: {visible: false, css:"area"}, - axisX:{ showAxis: true, label: G_STRING.ID_PROCESS_TASKS }, - axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS }, - showErrorBars: false - } - }; - - - - var generalBarParams1 = { - canvas : { - containerId:'generalGraph1', - width:300, - height:300, - stretch:true - }, - graph: { - allowDrillDown:false, - allowTransition:true, - axisX:{ showAxis: true, label: G_STRING.ID_YEAR }, - axisY:{ showAxis: true, label: "Q" }, - gridLinesX:false, - gridLinesY:true, - showTip: true, - allowZoom: true, - useShadows: true, - paddingTop: 50, - colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9'] - } - }; - - var generalBarParams2 = { - canvas : { - containerId:'generalGraph2', - width:300, - height:300, - stretch:true - }, - graph: { - allowDrillDown:false, - allowTransition:true, - axisX:{ showAxis: true, label: G_STRING.ID_YEAR }, - axisY:{ showAxis: true, label: "Q" }, - gridLinesX:false, - gridLinesY:true, - showTip: true, - allowZoom: true, - useShadows: true, - paddingTop: 50, - colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9'] - } - }; - var peiDetailParams = { - canvas : { - containerId:'proEfficGraph', - width:300, - height:300, - stretch:true - }, - graph: { - allowTransition: false, - allowDrillDown: true, - showTip: true, - allowZoom: false, - useShadows: false, - gridLinesX: true, - gridLinesY: true, - area: {visible: false, css:"area"}, - axisX:{ showAxis: true, label: G_STRING.ID_PROCESS_TASKS }, - axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS }, - showErrorBars: true - - } - }; - - var ueiDetailParams = { - canvas : { - containerId:'proEfficGraph', - width:300, - height:300, - stretch:true - }, - graph: { - allowTransition: false, - allowDrillDown: true, - showTip: true, - allowZoom: false, - useShadows: false, - gridLinesX: true, - gridLinesY: true, - area: {visible: false, css:"area"}, - axisX:{ showAxis: true, label: G_STRING.ID_USERS }, - axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS }, - showErrorBars: true - - } - }; - - //Adding data to - function animateprogress (id, index, comparative, name, indUid, direction){ - var getRequestAnimationFrame = function () { - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function ( callback ){ - window.setTimeout(enroute, 1 / 60 * 1000); - }; - }; - - var fpAnimationFrame = getRequestAnimationFrame(); - var i = 0; - var j = 0; - - if(name.length>20){ - name = name.substring( -20, 20 ); - name = name+"..."; - } - - index = validaNull(index); - - document.getElementById(id+"Huge"+indUid).innerHTML = index; - document.getElementById(id+"Small"+indUid).innerHTML = comparative; - document.getElementById(id+"Span"+indUid).innerHTML = name; - - if(id == "proEffic" || id == "userEffic"){ - if(comparative<0){ - if(id == "proEffic"){ - $(document.getElementsByClassName("proGreen")).removeClass("panel-green").addClass("panel-red"); - $(document.getElementsByClassName("up")).removeClass("fa-chevron-up").addClass("fa-chevron-down"); - } - } else if(comparative>=0){ - $(document.getElementsByClassName("proRed")).removeClass("panel-red").addClass("panel-green"); - if(comparative==0){ - $(document.getElementsByClassName("down")).removeClass("fa-chevron-down").addClass("fa-circle-o"); - $(document.getElementsByClassName("up")).removeClass("fa-chevron-up").addClass("fa-circle-o"); - } else { - $(document.getElementsByClassName("down")).removeClass("fa-chevron-down").addClass("fa-chevron-up"); - } - } - } - - if(id == "generalGreat" || id == "generalLow"){ - var animacion = function () { - var comp = parseInt(comparative); - $(document.getElementById(id+indUid)).attr('aria-valuemax', comp); - var indexToPaint = index*100/comp; - if (i<=indexToPaint) - { - $(document.getElementById(id+indUid)).css('width', i+'%').attr('aria-valuenow', i); - i++; - fpAnimationFrame(animacion); - } - - if(j<=index){ - document.getElementById(id+"Huge"+indUid).innerHTML = j+"%"; - j++; - fpAnimationFrame(animacion); - } - - var direc = (direction == "1")? "<" : ">"; - if(id == "generalLow"){ - document.getElementById(id+"Small"+indUid).innerHTML = "Goal "+direc+" "+comparative+"%"; - } else{//si esq es positivo mostramos Well Done y la clase q setea las letras en blanco - document.getElementById(id+"Small"+indUid).innerHTML = "("+direc+" "+comparative+" %) "+ G_STRING.ID_WELL_DONE; - } - } - fpAnimationFrame(animacion); - } - }; - - //Button by dashbutton - var dasButton = '
'; - - //Items by each type: - var proEffic = '
\ -
\ - \ -
\ -
'; - - var userEffic = '
\ -
\ - \ -
\ -
'; - - var compCases = '
\ -
\ - \ -
\ -
'; - - var numCases = '
\ -
\ - \ -
\ -
'; - - //Data by Indicator elements: - var proEfficDataGen = '
\ -
'+ G_STRING.ID_PRO_EFFICIENCY_INDEX +'
\ -
\ -
\ -
26%
\ -
'+ G_STRING.ID_EFFICIENCY_INDEX +'
\ -
\ -
\ -
$1813.50
\ -
'+ G_STRING.ID_INEFFICIENCY_COST +'
\ -
\ -
\ -
\ -
\ -
'; - - var proEfficData = '
\ -
\ - \ -
\ -
\ -
\ -
26%
\ -
'+ G_STRING.ID_EFFICIENCY_INDEX +'
\ -
\ -
\ -
$1813.50
\ -
'+ G_STRING.ID_INEFFICIENCY_COST +'
\ -
\ -
\ -
\ -
\ -
'; - - var proEfficDetail = '
\ -
\ - \ -
\ -
Process name 1
\ -
\ -
\ -
4.3 Days
\ -
'+ G_STRING.ID_EFFICIENCY_INDEX +'
\ -
\ -
\ -
1.3 Days
\ -
'+ G_STRING.ID_EFFICIENCY_COST +'
\ -
\ -
\ -
\ -
\ -
\ -
'; - - var proEfficTaskDetail = '
\ -
\ -
Task 1
\ -
\ -
\ -
\ -
\ -
\ -
0.95
\ -
'+ G_STRING.ID_EFFICIENCY_COST +'
\ -
\ -
\ -
4.3
\ -
Average Time
\ -
\ -
\ -
1.3
\ -
Deviation
\ -
\ -
\ -
\ -
\ -
'; - - var userTaskDetail = '
\ -
\ -
Task 1
\ -
\ -
\ -
\ -
\ -
\ -
0.95
\ -
'+ G_STRING.ID_EFFICIENCY_INDEX +'
\ -
\ -
\ -
\ -
1.3
\ -
'+ G_STRING.ID_INEFFICIENCY_COST +'
\ -
\ -
\ -
\ -
\ -
'; - - var generalDataLow = '
\ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
'; - - var generalDataGreat = '
\ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
'; - - var oType; - var actualDashId; - - //fecha actual - var date = new Date(); - var dateMonth = date.getMonth(); - var dateYear = date.getFullYear(); - - var dateActual = "01-"+(dateMonth+1)+"-"+dateYear; - var dateActualEnd = "30-"+(dateMonth)+"-"+dateYear; - - function validaNull(val){ - if(val === null || val == undefined || val == "?"){ - val = "?"; - } else { - val = (parseFloat(val)).toFixed(2); - } - return val; - }; - - function back(){ - if(oType=="proEffic"){ - var oID = $('.dashPro').attr("id"); - var oIDs = oID.split('Item'); - var id = oIDs[0]; - var uid = oIDs[1]; - - if($('.proGreen').hasClass('panel-red')){ - var comparative = -1; - } else if($('.proRed').hasClass('panel-green')){ - var comparative = +1; - } - - proxy.peiData(uid, dateActual, dateActualEnd, - function(dataIndicator){ - indicatorsData(dataIndicator, "proEffic", uid, comparative ); - }); - } else if(oType == "userEffic"){ - var oID = $('.dashUsr').attr("id"); - var oIDs = oID.split('Item'); - var id = oIDs[0]; - var uid = oIDs[1]; - - if($('.proRed').hasClass('panel-red')){ - var comparative = -1; - } else if($('.proRed').hasClass('panel-green')){ - var comparative = +1; - } - - proxy.ueiData(uid, dateActual, dateActualEnd, - function(dataIndicator){ - indicatorsData(dataIndicator, "userEffic", uid, comparative); - }); - } - }; - - /***** Adding Data by indicator *****/ - function indicatorsData(dataIndicator, type, indUid, comparative){ - $('#indicatorsDataGridStack').gridstack(); - var gridIndicators = $('#indicatorsDataGridStack').data('gridstack'), - widgetDetailDom; - gridIndicators.remove_all(); - - var gridProcess = $('#relatedDataGridStack').data('gridstack'); - gridProcess.remove_all(); - - oType = type; - switch (type) { - case 'proEffic': //Process Efficience Index - case 'userEffic': - var widget = proEfficDataGen; - var widgetDetail = proEfficDetail; - type = 'proEffic'; - break; - case 'generalGreat': - var widget = generalDataGreat; - var widgetDetail = ""; - break; - case 'generalLow': - var widget = generalDataLow; - var widgetDetail = ""; - break; - } - - //Drawing - gridIndicators.add_widget($(widget), 0, 15, 20, 4.7, true); //General data - - if(oType == "proEffic" || oType == "userEffic"){ - if(comparative<0){ - $(document.getElementsByClassName("greenbg")).removeClass("greenbg").addClass("redbg"); - $(document.getElementsByClassName("green")).removeClass("green").addClass("red"); - } else if(comparative>=0) { - $(document.getElementsByClassName("redbg")).removeClass("redbg").addClass("greenbg"); - } - } - - if (oType == "generalGreat" || oType == "generalLow") { - document.getElementById("relatedLabel").innerHTML = ""; - var graph1 = null; - if (dataIndicator.graph1Type == '10') { - generalBarParams1.graph.axisX.label = dataIndicator.graph1XLabel; - generalBarParams1.graph.axisY.label = dataIndicator.graph1YLabel; - graph1 = new BarChart(dataIndicator.graph1Data, generalBarParams1, null, null); - } else { - generalLineParams1.graph.axisX.label = dataIndicator.graph1XLabel; - generalLineParams1.graph.axisY.label = dataIndicator.graph1YLabel; - graph1 = new LineChart(dataIndicator.graph1Data, generalLineParams1, null, null); - } - graph1.drawChart(); - - var graph2 = null; - if (dataIndicator.graph2Type == '10') { - generalBarParams2.graph.axisX.label = dataIndicator.graph2XLabel; - generalBarParams2.graph.axisY.label = dataIndicator.graph2YLabel; - graph2 = new BarChart(dataIndicator.graph2Data, generalBarParams2, null, null); - } else { - generalLineParams2.graph.axisX.label = dataIndicator.graph2XLabel; - generalLineParams2.graph.axisY.label = dataIndicator.graph2YLabel; - graph2 = new LineChart(dataIndicator.graph2Data, generalLineParams2, null, null); - } - graph2.drawChart(); - } - - //ProEffic or userEffic - if(type == "proEffic" || type == "userEffic"){ - var inValue = validaNull(dataIndicator.efficiencyIndex); - var inCost = validaNull(dataIndicator.inefficiencyCost); - - document.getElementById(type+"Index").innerHTML = inValue; - document.getElementById(type+"Cost").innerHTML = "$" +inCost; - - //first level draw - if(oType == "proEffic") { - document.getElementById("relatedLabel").innerHTML = "

"+ G_STRING.ID_RELATED_PROCESS +"

"; - var graph = new Pie3DChart(dataIndicator.dataToDraw, peiParams, null, null); - graph.drawChart(); - } - - if(oType == "userEffic") { - document.getElementById("relatedLabel").innerHTML = "

"+ G_STRING.ID_RELATED_GROUPS +"

"; - var graph = new LineChart(dataIndicator.dataToDraw, ueiParams, null, null); - graph.drawChart(); - } - - //Data by process - for (i in dataIndicator.data){ - var proUid = dataIndicator.data[i].uid; - var proDataName = dataIndicator.data[i].name; - var proDataEfficiency = validaNull(dataIndicator.data[i].efficiencyIndex); - var proDataEfficCost = validaNull(dataIndicator.data[i].inefficiencyCost); - var x = 0; - if(i % 2 == 0){ - x = 6; - } - - widgetDetailDom = $(widgetDetail); - widgetDetailDom.attr('id', proUid); - - gridProcess.add_widget(widgetDetailDom, x, 15, 6, 2, true); - - if(comparative<0){ - $(document.getElementsByClassName("green")).removeClass("green").addClass("blue"); - } else if(comparative>=0){ - //$(document.getElementsByClassName("blue")).removeClass("blue").addClass("green"); - } - - if(proDataName.length>25){ - proDataName = proDataName.substring( -25, 25 ); - proDataName = proDataName+"..."; - } - - //charging data by process - //Process Title - $("#procGreyTitle").attr('id', "procGreyTitle"+proUid);//changin the id - document.getElementById("procGreyTitle"+proUid).innerHTML = ""+proDataName+""; - //'+ G_STRING.ID_PRO_EFFICIENCY_INDEX +' - $("#proIndex").attr('id', "proIndex"+proUid);//changin the id - document.getElementById("proIndex"+proUid).innerHTML = proDataEfficiency; - //Process Efficiency Cost - $("#proCost").attr('id', "proCost"+proUid);//changin the id - document.getElementById("proCost"+proUid).innerHTML = proDataEfficCost; - - widgetDetailDom.click(function(e){ - var proid = $(this).attr("id"); - var proname = $(this).find("#procGreyTitle"+proid).html(); - var proindex = validaNull($(this).find("#proIndex"+proid).html()); - var procost = validaNull($(this).find("#proCost"+proid).html()); - - gridIndicators.remove_all(); - gridProcess.remove_all(); - - //Drawing - gridIndicators.add_widget($(proEfficData), 0, 15, 20, 4.7, true); //General data of the process - if(comparative < 0){ - $(document.getElementsByClassName("greenbg")).removeClass("greenbg").addClass("redbg"); - $(document.getElementsByClassName("green")).removeClass("green").addClass("red"); - } else if(comparative > 0){ - $(document.getElementsByClassName("redbg")).removeClass("redbg").addClass("greenbg"); - //$(document.getElementsByClassName("red")).removeClass("red").addClass("green"); - } - - //adding data - //var name = $("#"+oType+"Span"+indUid).html(); - document.getElementById(type+"Title").innerHTML = name; - document.getElementById("proDetName").innerHTML = proname; - document.getElementById(type+"Index").innerHTML = proindex; - document.getElementById(type+"Cost").innerHTML = "$" +procost; - - //adding tasks - if(oType == "proEffic"){ - proxy.processTasksData(proid, dateActual, dateActualEnd, - function(dataTasks){ - tasksData(dataTasks, gridProcess, proid); - hideScrollIfAllDivsAreVisible(); - }); - } else { - proxy.userGroupData(proid, dateActual, dateActualEnd, - function(dataTasks){ - tasksData(dataTasks, gridProcess, proid); - hideScrollIfAllDivsAreVisible(); - }); - } - return false; - }); - } - hideScrollIfAllDivsAreVisible(); - } - //Adding the data by process - var name = $("#"+oType+"Span"+indUid).html(); - document.getElementById(type+"Title").innerHTML = name; - }; - - function tasksData(dataTasks, gridIndicators, proid){ - var i = 0; - if(oType == "proEffic"){ - document.getElementById("relatedLabel").innerHTML = "

"+ G_STRING.ID_RELATED_TASKS +"

"; - var graph = new LineChart(dataTasks.dataToDraw, peiDetailParams, null, null); - graph.drawChart(); - for (i in dataTasks.tasksData){ - var taskUid = dataTasks.tasksData[i].uid; - var taskName = dataTasks.tasksData[i].name; - var taskEffic = validaNull(dataTasks.tasksData[i].efficienceIndex); - var taskAverage = validaNull(dataTasks.tasksData[i].averageTime); - var taskDeviation = validaNull(dataTasks.tasksData[i].deviationTime); - var x = 0; - if(i % 2 == 0){ - x = 6; - } - - var widgetDetailTaskDom = $(proEfficTaskDetail); - widgetDetailTaskDom.attr('id', taskUid+"task"); - gridIndicators.add_widget(widgetDetailTaskDom, x, 15, 6, 2, true);//Drawing the task - - if($('.proGreen').hasClass('panel-red')){ - $(document.getElementsByClassName("greenbg")).removeClass("greenbg").addClass("redbg"); - }else { - $(document.getElementsByClassName("redbg")).removeClass("redbg").addClass("greenbg"); - } - - if(taskName.length>55){ - taskName = taskName.substring( -55, 55 ); - taskName = taskName+"..."; - } - - //Adding data to task - //Task Title - $("#taskName").attr('id', "taskName"+taskUid);//changin the id - document.getElementById("taskName"+taskUid).innerHTML = taskName; - //Task Efficiency Index - $("#taskEffic").attr('id', "taskEffic"+taskUid);//changin the id - document.getElementById("taskEffic"+taskUid).innerHTML = taskEffic; - //Task Average - $("#taskAver").attr('id', "taskAver"+taskUid);//changin the id - document.getElementById("taskAver"+taskUid).innerHTML = taskAverage; - //Task Deviation - $("#taskDeviat").attr('id', "taskDeviat"+taskUid);//changin the id - document.getElementById("taskDeviat"+taskUid).innerHTML = taskDeviation; - } - } else { - document.getElementById("relatedLabel").innerHTML = "

"+ G_STRING.ID_RELATED_USERS +"

"; - var graph = new LineChart(dataTasks.dataToDraw, ueiDetailParams, null, null); - graph.drawChart(); - for (i in dataTasks.tasksData){ - var usrUid = dataTasks.tasksData[i].userUid; - var usrName = dataTasks.tasksData[i].name; - var usrEffic = validaNull(dataTasks.tasksData[i].efficiencyIndex); - var usrCost = validaNull(dataTasks.tasksData[i].inefficiencyCost); - var x = 0; - if(i % 2 == 0){ - x = 6; - } - - var widgetDetailUsrDom = $(userTaskDetail); - widgetDetailUsrDom.attr('id', usrUid+"task"); - gridIndicators.add_widget(widgetDetailUsrDom, x, 15, 6, 2, true);//Drawing the task - - if($('.proRed').hasClass('panel-green')){ - $(document.getElementsByClassName("redbg")).removeClass("redbg").addClass("greenbg"); - } else{ - $(document.getElementsByClassName("greenbg")).removeClass("greenbg").addClass("redbg"); - } - - if(usrName.length>55){ - usrName = usrName.substring( -55, 55 ); - usrName = usrName+"..."; - } - - //Adding data to task - //Task Title - $("#usrName").attr('id', "usrName"+usrUid);//changin the id - document.getElementById("usrName"+usrUid).innerHTML = usrName; - //Task Efficiency Index - $("#usrEffic").attr('id', "usrEffic"+usrUid);//changin the id - document.getElementById("usrEffic"+usrUid).innerHTML = usrEffic; - //Task Deviation - $("#usrCost").attr('id', "usrCost"+usrUid);//changin the id - document.getElementById("usrCost"+usrUid).innerHTML = usrCost; - } - } - - - }; - - function hideScrollIfAllDivsAreVisible(){ - //For Debug: console.log('hidden ' + $('.hideme').length); - if ($('.hideme').length <= 0) { - $('#theImg').hide(); - } - else { - $('#theImg').show(); - } - } - - $( document ).ready(function() { - /* Show on scroll functionality... */ - $(window).scroll( function() { - /* Check the location of each desired element */ - $('.hideme').each( function(i){ - var bottom_of_object = $(this).offset().top + $(this).outerHeight(); - var bottom_of_window = $(window).scrollTop() + $(window).height(); - /* If the object is completely visible in the window, fade it in */ - if (bottom_of_window + 100 > bottom_of_object) { - $(this).animate({'opacity':'1'}, 500); - $(this).removeClass('hideme'); - } - }); - hideScrollIfAllDivsAreVisible(); - }); - - if(dateMonth == 0){ - document.getElementById('year').selectedIndex = 1; - document.getElementById('mounth').selectedIndex = 11; - }else{ - document.getElementById('mounth').selectedIndex = dateMonth-1; - } - - /*****calling the proxy*****/ - function getDashboardProxy(type) { - var ws = urlProxy.split('/'); - if (type.toLowerCase()=='test') - return new DashboardProxyTest(); - - if (type.toLowerCase()=='pro') - return new DashboardProxy(token, - urlProxy, - ws[3]); - }; - proxy = getDashboardProxy('pro'); - proxy.userDashboards(usrId, - function(dataDashboards){ - if(dataDashboards.length > 0){ - dashboardsButtons(dataDashboards); - }else{ - $(".indicators").append("

"+ G_STRING.ID_GRID_PAGE_NO_DASHBOARD_MESSAGE +"

"); - } - }); - - /*********************************/ - //ConfigurationObject - objConfigDashboards = [ - { - "dashUid": "15115651654654", - "favorite": 1, - "indicators":[ - { - /*"indUid": "15115651654654", - "indName": "Process Efficiency Index",*/ - "id": "proEffic", - "favorite": 1, - "x": 0, - "y": 6, - "height": "50px", - "width": "20px" - }, { - /*"indUid": "45165165165161", - "indName": "Completed Cases",*/ - "id": "compCases", - "favorite": 0, - "x": 6, - "y": 6, - "height": "50px", - "width": "20px" - } - ] - }, - { - "dashUid": "5645565165465", - "favorite": 0, - "indicators":[ - { - /*"indUid": "15115651654654", - "indName": "Number Cases",*/ - "id": "numCases", - "favorite": 0, - "x": 0, - "y": 6, - "height": "50px", - "width": "20px" - }, { - /*"indUid": "45165165165161", - "indName": "User Efficiency",*/ - "id": "userEffic", - "favorite": 1, - "x": 4, - "y": 6, - "height": "50px", - "width": "20px" - }, - { - /*"indUid": "45165165165161", - "indName": "Completed Cases",*/ - "id": "compCases", - "favorite": 0, - "x": 8, - "y": 6, - "height": "50px", - "width": "20px" - } - ] - } - ]; - - //When some item is moved - $('.grid-stack').on('change', function (e, items) { - var widgets = []; - _.map($('.grid-stack .grid-stack-item:visible'), function (el) { - el = $(el); - var item = el.data('_gridstack_node'); - var idWidGet = item.el[0].id.split('Item'); - if(favorite == actualDashId){ - favoriteData = 1; - } else { - favoriteData = 0; - } - if (typeof idWidGet[1] != "undefined") { - var widgetsObj = { - 'indicatorId': idWidGet[1], - 'x': item.x, - 'y': item.y, - 'width': item.width, - 'height': item.height <= 1 ? 2 : item.height - } - widgets.push(widgetsObj); - } - }); - - if (widgets.length != 0) { - var dashboard = { - 'dashId': actualDashId, - 'dashFavorite': favoriteData, - 'dashData': widgets - } - proxy.setPositionIndicator(dashboard); - } - }); - - - /*****Adding Buttons*****/ - function dashboardsButtons(dataDashboards){ - for( i in dataDashboards){ - var dashUid = dataDashboards[i].dashUid; - var dashName = dataDashboards[i].dashName; - var dashFavorite = dataDashboards[i].favorite; - - var domButton = $(dasButton); - - //adding a new button - $( "#dasbuttons" ).append( domButton ); - - //adding the UID like the id of the tag. - $("#dasB").attr('id', dashUid); - $("#favorite").attr('id', dashUid+'fav'); - - if(dashName.length>20){ - dashNameButton = dashName.substring( -20, 20 ); - dashNameButton = dashNameButton+"..."; - } else{ - dashNameButton = dashName; - } - - //addign the name - document.getElementById(dashUid).innerHTML = dashNameButton; - - //if it is favorite adding the selected class - if(dashFavorite == 1){ - actualDashId = dashUid; - favorite = actualDashId; - document.getElementById("titleH4").innerHTML = dashName; - $("#"+dashUid+"fav").addClass("selected"); - - //calling backend - proxy.dashboardIndicators(dashUid, dateActual, dateActualEnd, - function(widgetsObj) { - indicators(widgetsObj); - }); - } - - domButton.find("#"+dashUid+"fav").click(function() { - dashUid = $(this).siblings('.btn').attr("id"); - favorite = dashUid; - - $(".selected").removeClass("selected"); - $(this).addClass("selected"); - //call backend to save the favorite selection - var dashboard = { - 'dashId': dashUid, - 'dashFavorite': 1, - 'dashData': '' - } - proxy.setPositionIndicator(dashboard); - }); - - domButton.find("#"+dashUid).click(function() { - var btnid = $(this).attr("id"); - //first we have to get the divs empty - $('#indicatorsGridStack').gridstack(); - var gridDashboards = $('#indicatorsGridStack').data('gridstack'); - gridDashboards.remove_all(); - - $('#indicatorsDataGridStack').gridstack(); - var gridIndicators = $('#indicatorsDataGridStack').data('gridstack'); - gridIndicators.remove_all(); - - //changing the Name of the Dashboard - var btnName = $(this).html(); - document.getElementById("titleH4").innerHTML = btnName; - - actualDashId = btnid; - //calling backend - proxy.dashboardIndicators(btnid, dateActual, dateActualEnd, - function(widgetsObj) { - indicators(widgetsObj); - }); - }); - - } - }; - - - - /*****Adding the indicators*****/ - function indicators (widgetsObj){ - $('#indicatorsGridStack').gridstack(); - - serialization = GridStackUI.Utils.sort(widgetsObj); - var grid = $('#indicatorsGridStack').data('gridstack'); - //var width = 12 / widgetsObj.length; - var i = 1; - - _.each(serialization, function (node) { - if(node.x == 0){ - var x = 12 - (12/i); - }else { - var x = node.x; - } - if(node.y == 0){ - var y = 6; - }else { - var y = node.y; - } - - if(node.height == 0){ - node.height = 2; - } - if(node.width == 0){ - node.width = 12 / widgetsObj.length; - } - - node.comparative = validaNull(node.comparative); - - switch (node.id) { - case "1010": //Process Efficience Index - var widget = proEffic; - var id = "proEffic"; - break; - case "1030": //Employee Efficience Index - var widget = userEffic; - var id = "userEffic"; - break; - case "1020": - case "1040": - case "1050": - case "1060": - case "1070": - case "1080": - var indexI = parseFloat(node.index); - var comparativeI = parseFloat(node.comparative); - var condition = (node.direction == "1")? (indexI <= comparativeI) : (indexI >= comparativeI); - if(condition == true){ - var widget = numCases; //Great - var id = "generalGreat"; - } else { - var widget = compCases; //Low - var id = "generalLow"; - } - break; - } - - //var comparative = (parseFloat(node.comparative)).toFixed(2); - var widgetDom = $(widget); - - //Dibujando - grid.add_widget(widgetDom, x, y, node.width, node.height, true); //dibuja los elementos - - $("#"+id+"Item").attr('id', id+"Item"+node.indUid);//changin the id of the divs - $("#"+id+"Div").attr('id', id+"Div"+node.indUid); - $("#"+id+"Huge").attr('id', id+"Huge"+node.indUid); - $("#"+id+"Small").attr('id', id+"Small"+node.indUid); - $("#"+id+"M").attr('id', id+"M"+node.indUid); - $("#"+id+"Span").attr('id', id+"Span"+node.indUid); - - if(id =="generalGreat" || id == "generalLow"){ - $("#"+id).attr('id', id+node.indUid); - } - - //Showing the data panels if is the favorite - if(node.favorite == 1){ - //changing the class - if ($("#"+id+"M"+node.indUid).hasClass('panel-active')){ - //nada - }else{ - //changing classes to show selection - $(document.getElementsByClassName("panel-active")).removeClass("panel-active"); - $("#"+id+"M"+node.indUid).addClass("panel-active"); - } - - //Getting the data - if(id == "proEffic"){ - proxy.peiData(node.indUid, dateActual, dateActualEnd, - function(dataIndicator){ - indicatorsData(dataIndicator, "proEffic", node.indUid, node.comparative); - hideScrollIfAllDivsAreVisible(); - }); - } else if (id == "userEffic" ){ - proxy.ueiData(node.indUid, dateActual, dateActualEnd, - function(dataIndicator){ - indicatorsData(dataIndicator, "userEffic", node.indUid, node.comparative); - hideScrollIfAllDivsAreVisible(); - }); - } else { - proxy.generalIndicatorData(node.indUid, dateActual, dateActualEnd, - function(dataIndicator){ - var indexI = parseFloat(node.index); - var comparativeI = parseFloat(node.comparative); - var condition = (node.direction == "1")? (indexI <= comparativeI) : (indexI >= comparativeI); - if(condition == true){ //this are percentages - indicatorsData(dataIndicator, "generalGreat", node.indUid, node.comparative); - hideScrollIfAllDivsAreVisible(); - } else{ - indicatorsData(dataIndicator, "generalLow", node.indUid, node.comparative); - hideScrollIfAllDivsAreVisible(); - } - }); - } - } else { - $("#"+id+"M"+node.indUid).removeClass("panel-active"); - } - - //Animating the Indicators - animateprogress(id, node.index, node.comparative, node.indName, node.indUid, node.direction); //inserta datos en cada elemento - i++; - - hideScrollIfAllDivsAreVisible(); - /********Changing the class when the indicator item is selected********/ - widgetDom.click(function(){ - var oID = $(this).attr("id"); - - if(oID != undefined && oID.indexOf('Item') != -1){ - var comparative = 0; - var oIDs = oID.split('Item'); - var id = oIDs[0]; - var uid = oIDs[1]; - - if($(this).children().hasClass('panel-red')){ - var comparative = -1; - } else if($(this).children().hasClass('panel-green')){ - var comparative = +1; - } - - /*if ($("#"+id+"M"+uid).hasClass('panel-active')){ - //nada - }else{*/ - //changing classes to show selection - $(document.getElementsByClassName("panel-active")).removeClass("panel-active"); - $("#"+id+"M"+uid).addClass("panel-active"); - - //calling data of the indicator - if(id == "proEffic"){ - proxy.peiData(uid, dateActual, dateActualEnd, - function(dataIndicator){ - indicatorsData(dataIndicator, "proEffic", uid, comparative); - hideScrollIfAllDivsAreVisible(); - }); - } else if (id == "userEffic" ){ - proxy.ueiData(uid, dateActual, dateActualEnd, - function(dataIndicator){ - indicatorsData(dataIndicator, "userEffic", uid, comparative); - hideScrollIfAllDivsAreVisible(); - }); - } else { - proxy.generalIndicatorData(uid, dateActual, dateActualEnd, - function(dataIndicator){ - var index = $("#"+id+"Huge"+uid).html(); - index = parseInt(index); - var indexI = parseFloat(node.index); - var comparativeI = parseFloat(node.comparative); - var condition = (node.direction == "1")? (indexI <= comparativeI) : (indexI >= comparativeI); - if(condition == true){ //this are percentages - indicatorsData(dataIndicator, "generalGreat", uid, comparative); - } else{ - indicatorsData(dataIndicator, "generalLow", uid, comparative); - } - hideScrollIfAllDivsAreVisible(); - }); - } - - //} - } - }); - }); - }; - - $(".btn-compare").click(function(){ - var yearComp = $( "#year option:selected" ).text(); - var mounthComp = $( "#mounth option:selected" ).val(); - - dateActualEnd = "30-"+(mounthComp)+"-"+yearComp; - - //first we have to get the divs empty - $('#indicatorsGridStack').gridstack(); - var gridDashboards = $('#indicatorsGridStack').data('gridstack'); - gridDashboards.remove_all(); - - $('#indicatorsDataGridStack').gridstack(); - var gridIndicators = $('#indicatorsDataGridStack').data('gridstack'); - gridIndicators.remove_all(); - //For Debug: console.log(dateActualEnd); - //calling backend - proxy.dashboardIndicators(actualDashId, dateActual, dateActualEnd, - function(widgetsObj) { - indicators(widgetsObj); - }); - }); - - - }); - -$(function () { - var options = { - cell_height: 75, - vertical_margin: 12 - }; - $('.grid-stack').gridstack(options); -}); diff --git a/workflow/engine/js/strategicDashboard/dashboardProxy.js b/workflow/engine/js/strategicDashboard/dashboardProxy.js deleted file mode 100644 index b1669ecf7..000000000 --- a/workflow/engine/js/strategicDashboard/dashboardProxy.js +++ /dev/null @@ -1,500 +0,0 @@ - -var getKeyValue = -function getKeyValue(obj, key, undefined) { - var reg = /\./gi - , subKey - , keys - , context - , x - ; - - if (reg.test(key)) { - keys = key.split(reg); - context = obj; - - for (x = 0; x < keys.length; x++) { - subKey = keys[x]; - - //the values of all keys except for - //the last one should be objects - if (x < keys.length -1) { - if (!context.hasOwnProperty(subKey)) { - return undefined; - } - - context = context[subKey]; - } - else { - return context[subKey]; - } - } - } - else { - return obj[key]; - } -}; - -var setKeyValue = -function setKeyValue(obj, key, value) { - var reg = /\./gi - , subKey - , keys - , context - , x - ; - - //check to see if we need to process - //multiple levels of objects - if (reg.test(key)) { - keys = key.split(reg); - context = obj; - - for (x = 0; x < keys.length; x++) { - subKey = keys[x]; - - //the values of all keys except for - //the last one should be objects - if (x < keys.length -1) { - if (!context[subKey]) { - context[subKey] = {}; - } - - context = context[subKey]; - } - else { - context[subKey] = value; - } - } - } - else { - obj[key] = value; - } -}; - -var merge = -function merge(objFrom, objTo, propMap) { - var toKey - , fromKey - , x - , value - , def - , transform - , key - , keyIsArray - ; - - if (!objTo) { - objTo = {}; - } - - for(fromKey in propMap) { - if (propMap.hasOwnProperty(fromKey)) { - toKey = propMap[fromKey]; - - //force toKey to an array of toKeys - if (!Array.isArray(toKey)) { - toKey = [toKey]; - } - - for(x = 0; x < toKey.length; x++) { - def = null; - transform = null; - key = toKey[x]; - keyIsArray = Array.isArray(key); - - if (typeof(key) === "object" && !keyIsArray) { - def = key.default || null; - transform = key.transform || null; - key = key.key; - //evaluate if the new key is an array - keyIsArray = Array.isArray(key); - } - - if (keyIsArray) { - //key[toKeyName,transform,default] - def = key[2] || null; - transform = key[1] || null; - key = key[0]; - } - - if (def && typeof(def) === "function" ) { - def = def(objFrom, objTo); - } - - value = getKeyValue(objFrom, fromKey); - - if (transform) { - value = transform(value, objFrom, objTo); - } - - if (typeof value !== 'undefined') { - setKeyValue(objTo, key, value); - } - else if (typeof def !== 'undefined') { - setKeyValue(objTo, key, def); - } - } - } - } - - return objTo; -}; - -var DashboardProxy = function (oauthToken, server, workspace) { - this.server = server; - this.workspace = workspace; - this.baseUrl = "/api/1.0/" + workspace + "/"; - this.oauthToken = oauthToken; -}; - -DashboardProxy.prototype.userDashboards = function(userId, callBack) { - this.getJson('dashboard/ownerData/' + userId, - function (r) { - var returnList = []; - $.each(r, function(index, originalObject) { - var map = { - "DAS_TITLE" : "dashName", - "DAS_UID" : "dashUid", - "DAS_FAVORITE" : "favorite", - }; - - var newObject = merge(originalObject, {}, map); - returnList.push(newObject); - }); - callBack(returnList); - }); -}; - -DashboardProxy.prototype.dashboardIndicators = function(dashboardId, initDate, endDate, callBack) { - this.getJson('dashboard/' + dashboardId + '/indicator?dateIni=' + initDate + '&dateFin=' + endDate, - function (r) { - var returnList = []; - $.each(r, function(index, originalObject) { - var map = { - "DAS_IND_UID" : "indUid", - "DAS_IND_TITLE" : "indName", - "DAS_IND_TYPE" : "id", - "DAS_IND_VARIATION" : "comparative", - "DAS_IND_DIRECTION" : "direction", - "DAS_IND_VALUE" : "index", - "DAS_IND_X" : "x", - "DAS_IND_Y" : "y", - "DAS_IND_WIDTH" : "width", - "DAS_IND_HEIGHT" : "height", - "DAS_UID_PROCESS" : "process" - }; - - var newObject = merge(originalObject, {}, map); - //TODO do not burn this value. Data must come from the endpoint - newObject.favorite = ((returnList.length == 1) ? 1 : 0); - returnList.push(newObject); - }); - callBack(returnList); - }); -}; - -DashboardProxy.prototype.peiData = function(indicatorId, measureDate, compareDate, callBack) { - var endPoint = "ReportingIndicators/process-efficiency-data?" + - "indicator_uid=" + indicatorId + - "&measure_date=" + measureDate + - "&compare_date=" + compareDate + - "&language=en"; - this.getJson(endPoint, - function (r) { - var graphData = []; - $.each(r.data, function(index, originalObject) { - var map = { - "name" : "datalabel", - "inefficiencyCost" : "value" - }; - var newObject = merge(originalObject, {}, map); - var shortLabel = (newObject.datalabel == null) - ? "" - : newObject.datalabel.substring(0,15); - newObject.datalabel = shortLabel; - graphData.push(newObject); - }); - r.dataToDraw = graphData.splice(0,7); - callBack(r); - }); -} - -DashboardProxy.prototype.processTasksData = function(process, initDate, endDate, callBack) { - var endPoint = "ReportingIndicators/process-tasks?" + - "process_list=" + process + - "&init_date=" + initDate + - "&end_date=" + endDate + - "&language=en"; - this.getJson(endPoint, - function (r) { - var graphData = []; - $.each(r, function(index, originalObject) { - var map = { - "name" : "datalabel", - "averageTime" : "value", - "deviationTime" : "dispersion" - }; - var newObject = merge(originalObject, {}, map); - newObject.datalabel = newObject.datalabel.substring(0, 7); - graphData.push(newObject); - }); - var retval = {}; - retval.dataToDraw = graphData.splice(0,7); - retval.tasksData = r; - callBack(retval); - }); -} - -DashboardProxy.prototype.ueiData = function(indicatorId, measureDate, compareDate, callBack) { - var endPoint = "ReportingIndicators/employee-efficiency-data?" + - "indicator_uid=" + indicatorId + - "&measure_date=" + measureDate + - "&compare_date=" + compareDate + - "&language=en"; - this.getJson(endPoint, - function (r) { - var graphData = []; - $.each(r.data, function(index, originalObject) { - var map = { - "name" : "datalabel", - "averageTime" : "value", - "deviationTime" : "dispersion" - }; - var newObject = merge(originalObject, {}, map); - var shortLabel = (newObject.datalabel == null) - ? "" - : newObject.datalabel.substring(0,7); - - newObject.datalabel = shortLabel; - graphData.push(newObject); - }); - r.dataToDraw = graphData.splice(0,7); - callBack(r); - }); - - /*var retval = { - "efficiencyIndex":1.23, - "efficiencyVariation":0.23, - "inefficiencyCost":"$ 20112.23", - "employeeGroupsDataToDraw": - [ - {"value":"96", "datalabel":"User 1"}, - {"value":"84", "datalabel":"User 2"}, - {"value":"72", "datalabel":"User 3"}, - {"value":"18", "datalabel":"User 4"}, - {"value":"85", "datalabel":"User 5"} - ], - - "employeeGroupsData": [ - {"name": "User 1", "efficiencyIndex":"0.45", "innefficiencyCost":"$ 3404"}, - {"name": "User 2", "efficiencyIndex":"1.45", "innefficiencyCost":"$ 1404"}, - {"name": "User 3", "efficiencyIndex":"0.25", "innefficiencyCost":"$ 3304"}, - {"name": "User 4", "efficiencyIndex":"1.95", "innefficiencyCost":"$ 404"}, - {"name": "User 5", "efficiencyIndex":"1.25", "innefficiencyCost":"$ 13404"}, - {"name": "User 6", "efficiencyIndex":"0.75", "innefficiencyCost":"$ 4"} - ] - } - return retval;*/ -} - -DashboardProxy.prototype.userGroupData = function(groupId, initDate, endDate, callBack) { - var endPoint = "ReportingIndicators/group-employee-data?" + - "group_uid=" + groupId + - "&init_date=" + initDate + - "&end_date=" + endDate + - "&language=en"; - this.getJson(endPoint, - function (r) { - var graphData = []; - $.each(r, function(index, originalObject) { - var map = { - "name" : "datalabel", - "averageTime" : "value", - "deviationTime" : "dispersion" - }; - var newObject = merge(originalObject, {}, map); - newObject.datalabel = newObject.datalabel.substring(0, 7); - graphData.push(newObject); - }); - var retval = {}; - retval.dataToDraw = graphData.splice(0,7); - retval.tasksData = r; - callBack(retval); - }); -} - -DashboardProxy.prototype.generalIndicatorData = function(indicatorId, initDate, endDate, callBack) { - var method = ""; - var endPoint = "ReportingIndicators/general-indicator-data?" + - "indicator_uid=" + indicatorId + - "&init_date=" + initDate + - "&end_date=" + endDate + - "&language=en"; - this.getJson(endPoint, - function (r) { - $.each(r.graph1Data, function(index, originalObject) { - var label = (('YEAR' in originalObject) ? originalObject.YEAR : "") ; - label += (('MONTH' in originalObject) ? "/" + originalObject.MONTH : "") ; - label += (('QUARTER' in originalObject) ? "/" + originalObject.QUARTER : ""); - label += (('SEMESTER' in originalObject) ? "/" + originalObject.SEMESTER : ""); - originalObject.datalabel = label; - }); - - $.each(r.graph2Data, function(index, originalObject) { - var label = (('YEAR' in originalObject) ? originalObject.YEAR : "") ; - label += (('MONTH' in originalObject) ? "/" + originalObject.MONTH : "") ; - label += (('QUARTER' in originalObject) ? "/" + originalObject.QUARTER : ""); - label += (('SEMESTER' in originalObject) ? "/" + originalObject.SEMESTER : "") ; - originalObject.datalabel = label; - }); - callBack(r); - }); - - - - /*var retval = { - "index" : "23", - "graph1Data": [ - {"value":"96", "datalabel":"User 1"}, - {"value":"84", "datalabel":"User 2"}, - {"value":"72", "datalabel":"User 3"}, - {"value":"18", "datalabel":"User 4"}, - {"value":"85", "datalabel":"User 5"} - ], - "graph2Data": [ - {"value":"196", "datalabel":"User 1"}, - {"value":"184", "datalabel":"User 2"}, - {"value":"172", "datalabel":"User 3"}, - {"value":"118", "datalabel":"User 4"}, - {"value":"185", "datalabel":"User 5"} - ] - } - return retval;*/ -} - -DashboardProxy.prototype.userTasksData = function(processId, monthCompare, yearCompare) { - var retval = { - "tasksDataToDraw": [ - {"value":"96", "datalabel":"Task 1"}, - {"value":"84", "datalabel":"Task 2"}, - {"value":"72", "datalabel":"Task 3"}, - {"value":"18", "datalabel":"Task 4"}, - {"value":"85", "datalabel":"Task 5"} - ], - - "tasksData": [ - {"Name": "Task 1", "efficiencyIndex":"0.45", "deviationTime":"0.45", "averageTime":"34 days"}, - {"Name": "Task 2", "efficiencyIndex":"1.45", "deviationTime":"1.45", "averageTime":"14 days"}, - {"Name": "Task 3", "efficiencyIndex":"0.25", "deviationTime":"0.25", "averageTime":"3 days"}, - {"Name": "Task 4", "efficiencyIndex":"1.95", "deviationTime":"1.95", "averageTime":"4 days"}, - {"Name": "Task 5", "efficiencyIndex":"1.25", "deviationTime":"1.25", "averageTime":"14 days"}, - {"Name": "Task 6", "efficiencyIndex":"0.75", "deviationTime":"0.75", "averageTime":"4 days"} - ] - - } - return retval; -} - -DashboardProxy.prototype.getPositionIndicator = function(callBack) { - this.getJson('dashboard/config', function (r) { - var graphData = []; - $.each(r, function(index, originalObject) { - var map = { - "widgetId" : originalObject.widgetId, - "x" : originalObject.x, - "y" : originalObject.y, - "width" : originalObject.width, - "height" : originalObject.height - - }; - graphData.push(map); - }); - callBack(graphData); - }); -}; - -DashboardProxy.prototype.setPositionIndicator = function(data, callBack) { - var that = this; - - this.getPositionIndicator( - function(response){ - if (response.length != 0) { - that.putJson('dashboard/config', data, function (r) { - }); - } else { - that.postJson('dashboard/config', data, function (r) { - }); - } - } - ); -}; - - - -DashboardProxy.prototype.getJson = function (endPoint, callBack) { - var that = this; - var callUrl = this.baseUrl + endPoint - //For Debug: console.log('Llamando:'); - //For Debug: console.log(callUrl) - $.ajax({ - url: callUrl, - type: 'GET', - datatype: 'json', - success: function(response) { callBack(response); }, - error: function(jqXHR, textStatus, errorThrown) { - throw new Error(textStatus); - }, - beforeSend: function (xhr) { - xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken); - xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); - } - - }); -} - -DashboardProxy.prototype.postJson = function (endPoint, data, callBack) { - var that = this; - $.ajax({ - url : this.baseUrl + endPoint, - type : 'POST', - datatype : 'json', - contentType: "application/json; charset=utf-8", - data: JSON.stringify(data), - success: function(response) { - callBack(response); - }, - error: function(jqXHR, textStatus, errorThrown) { - throw new Error(textStatus); - }, - beforeSend: function (xhr) { - xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken); - xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); - } - }).fail(function () { - throw new Error('Fail server'); - }); -}; - - -DashboardProxy.prototype.putJson = function (endPoint, data, callBack) { - var that = this; - $.ajax({ - url : this.baseUrl + endPoint, - type : 'PUT', - datatype : 'json', - contentType: "application/json; charset=utf-8", - data: JSON.stringify(data), - success: function(response) { - callBack(response); - }, - error: function(jqXHR, textStatus, errorThrown) { - throw new Error(textStatus); - }, - beforeSend: function (xhr) { - xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken); - xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); - } - }).fail(function () { - throw new Error('Fail server'); - }); -}; diff --git a/workflow/engine/js/strategicDashboard/viewDashboardHelper.js b/workflow/engine/js/strategicDashboard/viewDashboardHelper.js new file mode 100644 index 000000000..82781ab9b --- /dev/null +++ b/workflow/engine/js/strategicDashboard/viewDashboardHelper.js @@ -0,0 +1,180 @@ + + +var ViewDashboardHelper = function () { +}; + +ViewDashboardHelper.prototype.userDashboards = function(userId, callBack) { +}; + +ViewDashboardHelper.prototype.stringIfNull = function (val){ + if(val === null || val == undefined || val == "?"){ + val = "?"; + } else { + val = (parseFloat(val)).toFixed(2); + } + return val; +}; + +ViewDashboardHelper.prototype.assert = function (condition, message) { + if (!condition) { + message = message || "Assertion failed"; + if (typeof Error !== "undefined") { + throw new Error(message); + } + throw message; // Fallback + } +} + +ViewDashboardHelper.prototype.truncateString = function (string, len) { + this.assert(len != null && len > 0, "Var len not valid. String must by truncated to a positive non zero length."); + this.assert(string != null, "var string can't be null."); + + var retval = ""; + if(string.length > len){ + retval = string.substring(0, len ) + "..."; + } + else{ + retval = string; + } + return retval; +} + +ViewDashboardHelper.prototype.getKeyValue = function (obj, key, undefined) { + var reg = /\./gi + , subKey + , keys + , context + , x + ; + + if (reg.test(key)) { + keys = key.split(reg); + context = obj; + + for (x = 0; x < keys.length; x++) { + subKey = keys[x]; + + //the values of all keys except for + //the last one should be objects + if (x < keys.length -1) { + if (!context.hasOwnProperty(subKey)) { + return undefined; + } + + context = context[subKey]; + } + else { + return context[subKey]; + } + } + } + else { + return obj[key]; + } +}; + +ViewDashboardHelper.prototype.setKeyValue = function (obj, key, value) { + var reg = /\./gi + , subKey + , keys + , context + , x + ; + + //check to see if we need to process + //multiple levels of objects + if (reg.test(key)) { + keys = key.split(reg); + context = obj; + + for (x = 0; x < keys.length; x++) { + subKey = keys[x]; + + //the values of all keys except for + //the last one should be objects + if (x < keys.length -1) { + if (!context[subKey]) { + context[subKey] = {}; + } + + context = context[subKey]; + } + else { + context[subKey] = value; + } + } + } + else { + obj[key] = value; + } +}; + +ViewDashboardHelper.prototype.merge = function (objFrom, objTo, propMap) { + var toKey + , fromKey + , x + , value + , def + , transform + , key + , keyIsArray + ; + + if (!objTo) { + objTo = {}; + } + + for(fromKey in propMap) { + if (propMap.hasOwnProperty(fromKey)) { + toKey = propMap[fromKey]; + + //force toKey to an array of toKeys + if (!Array.isArray(toKey)) { + toKey = [toKey]; + } + + for(x = 0; x < toKey.length; x++) { + def = null; + transform = null; + key = toKey[x]; + keyIsArray = Array.isArray(key); + + if (typeof(key) === "object" && !keyIsArray) { + def = key.default || null; + transform = key.transform || null; + key = key.key; + //evaluate if the new key is an array + keyIsArray = Array.isArray(key); + } + + if (keyIsArray) { + //key[toKeyName,transform,default] + def = key[2] || null; + transform = key[1] || null; + key = key[0]; + } + + if (def && typeof(def) === "function" ) { + def = def(objFrom, objTo); + } + + value = this.getKeyValue(objFrom, fromKey); + + if (transform) { + value = transform(value, objFrom, objTo); + } + + if (typeof value !== 'undefined') { + this.setKeyValue(objTo, key, value); + } + else if (typeof def !== 'undefined') { + this.setKeyValue(objTo, key, def); + } + } + } + } + + return objTo; +}; + + diff --git a/workflow/engine/js/strategicDashboard/viewDashboardModel.js b/workflow/engine/js/strategicDashboard/viewDashboardModel.js new file mode 100644 index 000000000..c2b63eca1 --- /dev/null +++ b/workflow/engine/js/strategicDashboard/viewDashboardModel.js @@ -0,0 +1,194 @@ +var ViewDashboardModel = function (oauthToken, server, workspace) { + this.server = server; + this.workspace = workspace; + this.baseUrl = "/api/1.0/" + workspace + "/"; + //this.baseUrl = "http://127.0.0.1:8080/api/1.0/workflow/"; + this.oauthToken = oauthToken; + this.helper = new ViewDashboardHelper(); + this.cache = []; + this.forceRemote=false; //if true, the next call will go to the remote server +}; + +ViewDashboardModel.prototype.userDashboards = function(userId) { + return this.getJson('dashboard/ownerData/' + userId); +}; + +ViewDashboardModel.prototype.dashboardIndicators = function(dashboardId, initDate, endDate) { + return this.getJson('dashboard/' + dashboardId + '/indicator?dateIni=' + initDate + '&dateFin=' + endDate); +}; + +ViewDashboardModel.prototype.peiData = function(indicatorId, compareDate, measureDate) { + var endPoint = "ReportingIndicators/process-efficiency-data?" + + "indicator_uid=" + indicatorId + + "&compare_date=" + compareDate + + "&measure_date=" + measureDate + + "&language=en"; + return this.getJson(endPoint); +} + +ViewDashboardModel.prototype.statusData = function() { + var endPoint = "ReportingIndicators/status-indicator"; + return this.getJson(endPoint); +} + +ViewDashboardModel.prototype.peiDetailData = function(process, initDate, endDate) { + var endPoint = "ReportingIndicators/process-tasks?" + + "process_list=" + process + + "&init_date=" + initDate + + "&end_date=" + endDate + + "&language=en"; + return this.getJson(endPoint); +} + +ViewDashboardModel.prototype.ueiData = function(indicatorId, compareDate, measureDate ) { + var endPoint = "ReportingIndicators/employee-efficiency-data?" + + "indicator_uid=" + indicatorId + + "&compare_date=" + compareDate + + "&measure_date=" + measureDate + + "&language=en"; + return this.getJson(endPoint); +} + +ViewDashboardModel.prototype.ueiDetailData = function(groupId, initDate, endDate) { + var endPoint = "ReportingIndicators/group-employee-data?" + + "group_uid=" + groupId + + "&init_date=" + initDate + + "&end_date=" + endDate + + "&language=en"; + return this.getJson(endPoint); +} + +ViewDashboardModel.prototype.generalIndicatorData = function(indicatorId, initDate, endDate) { + var method = ""; + var endPoint = "ReportingIndicators/general-indicator-data?" + + "indicator_uid=" + indicatorId + + "&init_date=" + initDate + + "&end_date=" + endDate + + "&language=en"; + return this.getJson(endPoint); +} + +ViewDashboardModel.prototype.getPositionIndicator = function(callBack) { + this.getJson('dashboard/config').done(function (r) { + var graphData = []; + $.each(r, function(index, originalObject) { + var map = { + "widgetId" : originalObject.widgetId, + "x" : originalObject.x, + "y" : originalObject.y, + "width" : originalObject.width, + "height" : originalObject.height + + }; + graphData.push(map); + }); + callBack(graphData); + }); +}; + +ViewDashboardModel.prototype.setPositionIndicator = function(data) { + var that = this; + + this.getPositionIndicator( + function(response){ + if (response.length != 0) { + that.putJson('dashboard/config', data); + } else { + that.postJson('dashboard/config', data); + } + } + ); +}; + +ViewDashboardModel.prototype.getJson = function (endPoint) { + var that = this; + var callUrl = this.baseUrl + endPoint + var requestFinished = $.Deferred(); + var itemInCache = that.getCacheItem(endPoint); + + if (itemInCache != null && !this.forceRemote) { + that.forceRemote = false; + requestFinished.resolve(itemInCache); + return requestFinished.promise(); + } + else { + return $.ajax({ + url: callUrl, + type: 'GET', + datatype: 'json', + success: function (data) { + that.forceRemote = false; + requestFinished.resolve(data); + that.putInCache(endPoint, data); + // return requestFinished.promise(); + }, + error: function(jqXHR, textStatus, errorThrown) { + throw new Error(callUrl + ' -- ' + errorThrown); + }, + beforeSend: function (xhr) { + xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken); + //xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); + } + }); + } +} + +ViewDashboardModel.prototype.postJson = function (endPoint, data) { + var that = this; + return $.ajax({ + url : this.baseUrl + endPoint, + type : 'POST', + datatype : 'json', + contentType: "application/json; charset=utf-8", + data: JSON.stringify(data), + error: function(jqXHR, textStatus, errorThrown) { + throw new Error(errorThrown); + }, + beforeSend: function (xhr) { + xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken); + xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); + } + }).fail(function () { + throw new Error('Fail server'); + }); +}; + +ViewDashboardModel.prototype.putJson = function (endPoint, data) { + var that = this; + return $.ajax({ + url : this.baseUrl + endPoint, + type : 'PUT', + datatype : 'json', + contentType: "application/json; charset=utf-8", + data: JSON.stringify(data), + error: function(jqXHR, textStatus, errorThrown) { + throw new Error(errorThrown); + }, + beforeSend: function (xhr) { + xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken); + //xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); + } + }).fail(function () { + throw new Error('Fail server'); + }); +}; + +ViewDashboardModel.prototype.getCacheItem = function (endPoint) { + var retval = null; + $.each(this.cache, function(index, objectItem) { + if (objectItem.key == endPoint) { + retval = objectItem.value; + } + }); + return retval; +} + +ViewDashboardModel.prototype.putInCache = function (endPoint, data) { + var cacheItem = this.getCacheItem(endPoint); + if (cacheItem == null) { + this.cache.push ({ key: endPoint, value:data }); + } + else { + cacheItem.value = data; + } +} diff --git a/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js b/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js new file mode 100644 index 000000000..703e3780e --- /dev/null +++ b/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js @@ -0,0 +1,381 @@ + + +var ViewDashboardPresenter = function (model) { + this.helper = new ViewDashboardHelper(); + this.helper.assert(model != null, "A model must be passed for the presenter work.") + this.model = model; +}; + +ViewDashboardPresenter.prototype.getUserDashboards = function (userId) { + var that = this; + var requestFinished = $.Deferred(); + that.model.userDashboards(userId) + .done(function(modelData){ + var viewModel = that.userDashboardsViewModel(modelData) + requestFinished.resolve(viewModel); + }); + return requestFinished.promise(); +}; + +ViewDashboardPresenter.prototype.userDashboardsViewModel = function(data) { + var that = this; + //if null data is returned we default to an empty array + if (data == null) { data = []; } + var returnList = []; + $.each(data, function(index, originalObject) { + var map = { + "DAS_TITLE" : "title", + "DAS_UID" : "id", + "DAS_FAVORITE" : "isFavorite" + }; + var newObject = that.helper.merge(originalObject, {}, map); + returnList.push(newObject); + }); + return returnList; +}; + +ViewDashboardPresenter.prototype.getDashboardIndicators = function (dashboardId,initDate, endDate) { + if (dashboardId == null) {throw new Error ("getDashboardIndicators -> dashboardId can't be null");}; + var that = this; + var requestFinished = $.Deferred(); + this.model.dashboardIndicators (dashboardId, initDate, endDate) + .done(function (modelData) { + var viewModel = that.dashboardIndicatorsViewModel(modelData) + requestFinished.resolve(viewModel); + }); + return requestFinished.promise(); +}; + +ViewDashboardPresenter.prototype.dashboardIndicatorsViewModel = function(data) { + var that = this; + var returnList = []; + var i = 1; + $.each(data, function(index, originalObject) { + var map = { + "DAS_IND_UID" : "id", + "DAS_IND_TITLE" : "title", + "DAS_IND_TYPE" : "type", + "DAS_IND_VARIATION" : "comparative", + "DAS_IND_DIRECTION" : "direction", + "DAS_IND_VALUE" : "value", + "DAS_IND_X" : "x", + "DAS_IND_Y" : "y", + "DAS_IND_WIDTH" : "width", + "DAS_IND_HEIGHT" : "height", + "DAS_UID_PROCESS" : "process", + "PERCENTAGE_OVERDUE" : "percentageOverdue", + "PERCENTAGE_AT_RISK" : "percentageAtRisk", + "PERCENTAGE_ON_TIME" : "percentageOnTime" + }; + + var newObject = that.helper.merge(originalObject, {}, map); + newObject.toDrawX = newObject.x; + //newObject.toDrawX = (newObject.x == 0) ? 12 - 12/i : newObject.x; + + newObject.toDrawY = (newObject.y == 0) ? 6 : newObject.y; + newObject.toDrawHeight = (newObject.y == 0) ? 2 : newObject.height; + newObject.toDrawWidth = (newObject.y == 0) ? 12 / data.length : newObject.width; + newObject.comparative = ((newObject.comparative > 0)? "+": "") + that.helper.stringIfNull(newObject.comparative); + newObject.directionSymbol = (newObject.direction == "1") ? "<" : ">"; + newObject.isWellDone = (newObject.direction == "1") + ? parseFloat(newObject.value) <= parseFloat(newObject.comparative) + : parseFloat(newObject.value) >= parseFloat(newObject.comparative); + + newObject.category = (newObject.type == "1010" || newObject.type == "1030") + ? "special" + : "normal"; + + //round goals for normal indicators + newObject.comparative = (newObject.category == "normal") + ? Math.round(newObject.comparative) + "" + : newObject.comparative; + + 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.atRiskVisiblity = (newObject.percentageAtRisk > 0)? "visible" : "hidden"; + newObject.onTimeVisibility = (newObject.percentageOnTime > 0)? "visible" : "hidden"; + returnList.push(newObject); + i++; + }); + + //sort the array for drawing in toDrawX order + returnList.sort(function (a, b) { + return ((a.toDrawX <= b.toDrawX) ? -1 : 1); + }); + if (returnList.length > 0) { + returnList[0].favorite = 1; + } + return returnList; +}; + +/*++++++++ FIRST LEVEL INDICATOR DATA +++++++++++++*/ +ViewDashboardPresenter.prototype.getIndicatorData = function (indicatorId, indicatorType, initDate, endDate) { + var that = this; + var requestFinished = $.Deferred(); + switch (indicatorType) { + case "1010": + this.model.peiData(indicatorId, initDate, endDate) + .done(function(modelData) { + var viewModel = that.peiViewModel(modelData) + requestFinished.resolve(viewModel); + }); + break; + case "1030": + this.model.ueiData(indicatorId, initDate, endDate) + .done(function(modelData) { + var viewModel = that.ueiViewModel(modelData) + requestFinished.resolve(viewModel); + }); + break; + case "1050": + this.model.statusData(indicatorId) + .done(function(modelData) { + var viewModel = that.statusViewModel(indicatorId, modelData) + requestFinished.resolve(viewModel); + }); + break; + default: + this.model.generalIndicatorData(indicatorId, initDate, endDate) + .done(function(modelData) { + var viewModel = that.indicatorViewModel(modelData) + requestFinished.resolve(viewModel); + }); + break; + } + return requestFinished.promise(); +}; + +ViewDashboardPresenter.prototype.peiViewModel = function(data) { + var that = this; + var graphData = []; + $.each(data.data, function(index, originalObject) { + var map = { + "name" : "datalabel", + "inefficiencyCost" : "value" + }; + var newObject = that.helper.merge(originalObject, {}, map); + var shortLabel = (newObject.datalabel == null) + ? "" + : newObject.datalabel.substring(0,15); + + newObject.datalabel = shortLabel; + graphData.push(newObject); + originalObject.inefficiencyCostToShow = "$ " + Math.round(originalObject.inefficiencyCost); + originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100; + originalObject.indicatorId = data.id; + originalObject.json = JSON.stringify(originalObject); + }); + + var retval = {}; + retval = data; + graphData.sort(function(a,b) { + var retval = 0; + retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1); + return retval; + }) + retval.dataToDraw = graphData.splice(0,7); + //TODO aumentar el símbolo de moneda $ + retval.inefficiencyCostToShow = "$ " +Math.round(retval.inefficiencyCost); + retval.efficiencyIndexToShow = Math.round(retval.efficiencyIndex * 100) / 100; + return retval; +}; + +ViewDashboardPresenter.prototype.ueiViewModel = function(data) { + var that = this; + var graphData = []; + $.each(data.data, function(index, originalObject) { + var map = { + "name" : "datalabel", + "inefficiencyCost" : "value", + "deviationTime" : "dispersion" + }; + var newObject = that.helper.merge(originalObject, {}, map); + var shortLabel = (newObject.datalabel == null) + ? "" + : newObject.datalabel.substring(0,7); + + newObject.datalabel = shortLabel; + graphData.push(newObject); + originalObject.inefficiencyCostToShow = "$ " + Math.round(originalObject.inefficiencyCost); + originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100; + originalObject.indicatorId = data.id; + originalObject.json = JSON.stringify(originalObject); + }); + + var retval = {}; + retval = data; + graphData.sort(function(a,b) { + var retval = 0; + retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1); + return retval; + }) + retval.dataToDraw = graphData.splice(0,7); + //TODO aumentar el símbolo de moneda $ + retval.inefficiencyCostToShow = "$ " + Math.round(retval.inefficiencyCost); + retval.efficiencyIndexToShow = Math.round(retval.efficiencyIndex * 100) / 100; + return retval; +}; + +ViewDashboardPresenter.prototype.statusViewModel = function(indicatorId, data) { + var that = this; + data.id = indicatorId; + var graph1Data = []; + var graph2Data = []; + var graph3Data = []; + $.each(data.dataList, function(index, originalObject) { + var title = (originalObject.taskTitle == null) + ? "" + : originalObject.taskTitle.substring(0,15); + var newObject1 = { + datalabel : title, + value : originalObject.percentageTotalOverdue + }; + var newObject2 = { + datalabel : title, + value : originalObject.percentageTotalAtRisk + }; + var newObject3 = { + datalabel : title, + value : originalObject.percentageTotalOnTime + }; + + graph1Data.push(newObject1); + graph2Data.push(newObject2); + graph3Data.push(newObject3); + //we add the indicator id for reference + originalObject.indicatorId = indicatorId; + }); + + var retval = data; + //TODO selecte de 7 worst cases no the first 7 + retval.graph1Data = graph1Data.splice(0,7) + retval.graph2Data = graph2Data.splice(0,7) + retval.graph3Data = graph3Data.splice(0,7) + + return retval; +}; + +ViewDashboardPresenter.prototype.indicatorViewModel = function(data) { + var that = this; + $.each(data.graph1Data, function(index, originalObject) { + var label = (('YEAR' in originalObject) ? originalObject.YEAR : "") ; + label += (('MONTH' in originalObject) ? "/" + originalObject.MONTH : "") ; + label += (('QUARTER' in originalObject) ? "/" + originalObject.QUARTER : ""); + label += (('SEMESTER' in originalObject) ? "/" + originalObject.SEMESTER : ""); + originalObject.datalabel = label; + }); + + $.each(data.graph2Data, function(index, originalObject) { + var label = (('YEAR' in originalObject) ? originalObject.YEAR : "") ; + label += (('MONTH' in originalObject) ? "/" + originalObject.MONTH : "") ; + label += (('QUARTER' in originalObject) ? "/" + originalObject.QUARTER : ""); + label += (('SEMESTER' in originalObject) ? "/" + originalObject.SEMESTER : "") ; + originalObject.datalabel = label; + }); + return data; +}; +/*-------FIRST LEVEL INDICATOR DATA */ + +/*++++++++ SECOND LEVEL INDICATOR DATA +++++++++++++*/ +ViewDashboardPresenter.prototype.getSpecialIndicatorSecondLevel = function (entityId, indicatorType, initDate, endDate) { + var that = this; + var requestFinished = $.Deferred(); + //if modelData is passed (because it was cached on the view) no call is made to the server. + //and just a order is applied to the list + + switch (indicatorType) { + case "1010": + this.model.peiDetailData(entityId, initDate, endDate) + .done(function (modelData) { + var viewModel = that.returnIndicatorSecondLevelPei(modelData); + requestFinished.resolve(viewModel); + }); + break; + case "1030": + this.model.ueiDetailData(entityId, initDate, endDate) + .done(function (modelData) { + var viewModel = that.returnIndicatorSecondLevelUei(modelData); + requestFinished.resolve(viewModel); + }); + break; + default: + throw new Error("Indicator type " + indicatorType + " has not detail data implemented of special indicator kind."); + } + return requestFinished.promise(); +}; + +ViewDashboardPresenter.prototype.returnIndicatorSecondLevelPei = function(modelData) { + //modelData arrives in format [{users/tasks}] + //returns object {dataToDraw[], entityData[] //user/tasks data} + var that = this; + var graphData = []; + + $.each(modelData, function(index, originalObject) { + var map = { + "name" : "datalabel", + "averageTime" : "value", + "deviationTime" : "dispersion" + }; + var newObject = that.helper.merge(originalObject, {}, map); + newObject.datalabel = ((newObject.datalabel == null) ? "" : newObject.datalabel.substring(0, 7)); + originalObject.inefficiencyCostToShow = "$ " + Math.round(originalObject.inefficiencyCost); + originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100; + graphData.push(newObject); + }); + var retval = {}; + retval.dataToDraw = graphData.splice(0,7); + retval.entityData = modelData; + return retval; +}; + +ViewDashboardPresenter.prototype.returnIndicatorSecondLevelUei = function(modelData) { + //modelData arrives in format [{users/tasks}] + //returns object {dataToDraw[], entityData[] //user/tasks data} + var that = this; + var graphData = []; + + $.each(modelData, function(index, originalObject) { + var map = { + "name" : "datalabel", + "averageTime" : "value", + "deviationTime" : "dispersion" + }; + var newObject = that.helper.merge(originalObject, {}, map); + newObject.datalabel = ((newObject.datalabel == null) ? "" : newObject.datalabel.substring(0, 7)); + originalObject.inefficiencyCostToShow = "$ " +Math.round(originalObject.inefficiencyCost); + originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100; + graphData.push(newObject); + }); + var retval = {}; + retval.dataToDraw = graphData.splice(0,7); + retval.entityData = modelData; + return retval; +}; +/*-------SECOND LEVEL INDICATOR DATA*/ + +ViewDashboardPresenter.prototype.orderDataList = function(listData, orderDirection, orderFunction) { + //orderDirection is passed in case no order FUnction is passed (to use in the default ordering) + var orderToUse = orderFunction; + if (orderFunction == undefined) { + orderToUse = function (a ,b) { + var retval = 0; + if (orderDirection == "down") { + retval = ((a.inefficiencyCost*1.0 <= b.inefficiencyCost*1.0) ? 1 : -1); + } + else { + //the 1,-1 are flipped + retval = ((a.inefficiencyCost*1.0 <= b.inefficiencyCost*1.0) ? -1 : 1); + } + return retval; + } + } + return listData.sort(orderToUse); +} diff --git a/workflow/engine/js/strategicDashboard/viewDashboardView.js b/workflow/engine/js/strategicDashboard/viewDashboardView.js new file mode 100644 index 000000000..a7ced8a77 --- /dev/null +++ b/workflow/engine/js/strategicDashboard/viewDashboardView.js @@ -0,0 +1,904 @@ +/**************************************************************/ +var WidgetBuilder = function () { + this.helper = new ViewDashboardHelper(); +} + +WidgetBuilder.prototype.getIndicatorWidget = function (indicator) { + var retval = null; + switch(indicator.type) { + case "1010": retval = this.buildSpecialIndicatorButton(indicator); break; + case "1030": retval = this.buildSpecialIndicatorButton(indicator); break; + case "1050": retval = this.buildStatusIndicatorButton(indicator); break; + case "1020": + case "1040": + case "1060": + case "1070": + case "1080": + retval = this.buildIndicatorButton(indicator); break; + } + if(retval == null) {throw new Error(indicator.type + " has not associated a widget.");} + return retval; +}; + +WidgetBuilder.prototype.buildSpecialIndicatorButton = function (indicator) { + _.templateSettings.variable = "indicator"; + var template = _.template ($("script.specialIndicatorButtonTemplate").html()); + var $retval = $(template(indicator)); + + if(indicator.comparative < 0){ + $retval.find(".ind-container-selector").removeClass("panel-green").addClass("panel-red"); + $retval.find(".ind-symbol-selector").removeClass("fa-chevron-up").addClass("fa-chevron-down"); + } + + if(indicator.comparative > 0){ + $retval.find(".ind-container-selector").removeClass("panel-red").addClass("panel-green"); + $retval.find(".ind-symbol-selector").removeClass("fa-chevron-down").addClass("fa-chevron-up"); + } + + if(indicator.comparative == 0){ + $retval.find(".ind-symbol-selector").removeClass("fa-chevron-up"); + $retval.find(".ind-symbol-selector").removeClass("fa-chevron-down"); + $retval.find(".ind-symbol-selector").addClass("fa-circle-o"); + $retval.find(".ind-container-selector").removeClass("panel-red").addClass("panel-green"); + } + return $retval; +} + +WidgetBuilder.prototype.buildStatusIndicatorButton = function (indicator) { + _.templateSettings.variable = "indicator"; + var template = _.template ($("script.statusIndicatorButtonTemplate").html()); + var $retval = $(template(indicator)); + return $retval; +} + +WidgetBuilder.prototype.buildIndicatorButton = function (indicator) { + _.templateSettings.variable = "indicator"; + var template = _.template ($("script.statusIndicatorButtonTemplate").html()); + var $retval = $(template(indicator)); + var $comparative = $retval.find('.ind-comparative-selector'); + var $title = $retval.find('.ind-title-selector'); + if (indicator.isWellDone) { + $comparative.text("(" + indicator.directionSymbol + " " + indicator.comparative + "%)-"+ G_STRING.ID_WELL_DONE); + $retval.find(".ind-container-selector").removeClass("panel-low").addClass("panel-high"); + } + else { + $comparative.text("Goal: " + indicator.directionSymbol + " " + indicator.comparative + "%"); + $retval.find(".ind-container-selector").removeClass("panel-high").addClass("panel-low"); + } + return $retval; +} + +WidgetBuilder.prototype.buildSpecialIndicatorFirstView = function (indicatorData) { + if (indicatorData == null) { throw new Error ("indicatorData is null."); } + if (!indicatorData.hasOwnProperty("id")) { throw new Error ("indicatorData has no id."); } + + _.templateSettings.variable = "indicator"; + var template = _.template ($("script.specialIndicatorMainPanel").html()); + var $retval = $(template(indicatorData)); + var indicatorPrincipalData = this.getIndicatorLoadedById(indicatorData.id) + $retval.find('.breadcrumb').find('li').remove() + $retval.find('.breadcrumb').append ('
  • '+indicatorPrincipalData.title+'
  • ') + $retval.find(".sind-index-selector").text(G_STRING.ID_EFFICIENCY_INDEX); + $retval.find(".sind-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST); + this.setColorForInefficiency($retval.find(".sind-cost-number-selector"), indicatorData); + return $retval; +} + +WidgetBuilder.prototype.buildSpecialIndicatorFirstViewDetail = function (oneItemDetail) { + //detailData = {indicatorId, uid, name, averateTime...} + if (oneItemDetail == null){throw new Error("oneItemDetail is null ");} + if (!typeof(oneItemDetail) === 'object'){throw new Error( "detailData is not and object ->" + oneItemDetail);} + if (!oneItemDetail.hasOwnProperty("name")){throw new Error("buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail);} + + _.templateSettings.variable = "detailData"; + var template = _.template ($("script.specialIndicatorDetail").html()); + var $retval = $(template(oneItemDetail)); + $retval.find(".detail-efficiency-selector").text(G_STRING.ID_EFFICIENCY_INDEX); + $retval.find(".detail-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST); + this.setColorForInefficiency($retval.find(".detail-cost-number-selector"), oneItemDetail); + return $retval; +} + +WidgetBuilder.prototype.buildStatusIndicatorFirstView = function (indicatorData) { + if (indicatorData == null) { throw new Error ("indicatorData is null."); } + if (!indicatorData.hasOwnProperty("id")) { throw new Error ("indicatorData has no id."); } + + _.templateSettings.variable = "indicator"; + var template = _.template ($("script.statusIndicatorMainPanel").html()); + var $retval = $(template(indicatorData)); + var indicatorPrincipalData = this.getIndicatorLoadedById(indicatorData.id) + $retval.find('.breadcrumb').find('li').remove() + $retval.find('.breadcrumb').append ('
  • '+indicatorPrincipalData.title+'
  • ') + return $retval; +} + +WidgetBuilder.prototype.buildStatusIndicatorFirstViewDetail = function (oneItemDetail) { + //detailData = {indicatorId, uid, name, averateTime...} + if (oneItemDetail == null){throw new Error("oneItemDetail is null ");} + if (!typeof(oneItemDetail) === 'object'){throw new Error( "detailData is not and object ->" + oneItemDetail);} + if (!oneItemDetail.hasOwnProperty("taskTitle")){throw new Error("detailData has not the name param. Has it the correct Type? ->" + oneItemDetail);} + + _.templateSettings.variable = "detailData"; + var template = _.template ($("script.statusDetail").html()); + var $retval = $(template(oneItemDetail)); + return $retval; +} + +WidgetBuilder.prototype.buildSpecialIndicatorSecondView = function (secondViewData) { + //presenterData= object {dataToDraw[], entityData[] //user/tasks data} + _.templateSettings.variable = "indicator"; + var template = _.template ($("script.specialIndicatorMainPanel").html()); + var $retval = $(template(window.currentEntityData)); + //var indicatorPrincipalData = this.getIndicatorLoadedById(indicatorId); + //$retval.find(".sind-title-selector").text(indicatorPrincipalData.title); + $retval.find(".sind-index-selector").text(G_STRING.ID_EFFICIENCY_INDEX); + $retval.find(".sind-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST); + + + $retval.find('.breadcrumb').find('li').remove(); + $retval.find('.breadcrumb').append ('
  • ' + window.currentIndicator.title + '
  • '); + $retval.find('.breadcrumb').append ('
  • ' + window.currentEntityData.name + '
  • '); + this.setColorForInefficiency($retval.find(".sind-cost-number-selector"), window.currentEntityData); + return $retval; +}; + +WidgetBuilder.prototype.buildSpecialIndicatorSecondViewDetail = function (oneItemDetail) { + if (oneItemDetail == null){throw new Error("oneItemDetail is null ");} + if (!typeof(oneItemDetail) === 'object'){throw new Error( "detailData is not and object ->" + oneItemDetail);} + if (!oneItemDetail.hasOwnProperty("name")){throw new Error("buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail);} + + _.templateSettings.variable = "detailData"; + var template = _.template ($("script.specialIndicatorSencondViewDetail").html()); + var $retval = $(template(oneItemDetail)); + $retval.find(".detail-efficiency-selector").text(G_STRING.ID_EFFICIENCY_INDEX); + $retval.find(".detail-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST); + this.setColorForInefficiency($retval.find(".detail-cost-number-selector"), oneItemDetail); + return $retval; +} + +WidgetBuilder.prototype.getIndicatorLoadedById = function (searchedIndicatorId) { + var retval = null; + for (key in window.loadedIndicators) { + var indicator = window.loadedIndicators[key]; + if (indicator.id == searchedIndicatorId) { + retval = indicator; + } + } + if (retval == null) { throw new Error(searchedIndicatorId + " was not found in the loaded indicators.");} + return retval; +} + +WidgetBuilder.prototype.buildGeneralIndicatorFirstView = function (indicatorData) { + _.templateSettings.variable = "indicator"; + var template = _.template ($("script.generalIndicatorMainPanel").html()); + var $retval = $(template(indicatorData)); + $retval.find(".ind-title-selector").text(window.currentIndicator.title); + return $retval; +} + + +WidgetBuilder.prototype.setColorForInefficiency = function ($widget, indicatorData) { + //turn red/gree the font according if is positive or negative: var $widget = $retval.find(".sind-cost-number-selector"); + $widget.removeClass("red"); + $widget.removeClass("green"); + if (indicatorData.inefficiencyCost >= 0) { + $widget.addClass("green"); + } + else { + $widget.addClass("red"); + } +} + +/**********************************************************************/ +helper = new ViewDashboardHelper(); +var ws = urlProxy.split('/'); +model = new ViewDashboardModel(token, urlProxy, ws[3]); +presenter = new ViewDashboardPresenter(model); + +window.loadedIndicators = []; //updated in das-title-selector.click->fillIndicatorWidgets, ready->fillIndicatorWidgets +window.currentEntityData = null; +window.currentIndicator = null;//updated in ind-button-selector.click ->loadIndicator, ready->loadIndicator +window.currentDashboardId = null; +window.currentDetailFunction = null; +window.currentDetailList = null; + +$(document).ready(function() { + $('#indicatorsGridStack').gridstack(); + $('#indicatorsDataGridStack').gridstack(); + $('#relatedDetailGridStack').gridstack(); + + $('#sortListButton').click(function() { + var btn = $(this); + if (btn.hasClass('fa-chevron-up')) { + btn.removeClass('fa-chevron-up'); + btn.addClass('fa-chevron-down'); + } + else { + btn.removeClass('fa-chevron-down'); + btn.addClass('fa-chevron-up'); + } + + window.currentDetailFunction (presenter.orderDataList ( + window.currentDetailList, + selectedOrderOfDetailList())); + //send scroll +1 and -1 to activate the show/hide event. + //both scrolls are sent cause if the scroll at the end + //scroll +1 has no effect but -1 yes + $(window).scrollTop($(window).scrollTop() + 1); + $(window).scrollTop($(window).scrollTop() - 1); + return false; + }); + + /* Show on scroll functionality */ + $(window).scroll( function() { + /* Check the location of each desired element */ + $('.hideme').each( function(i){ + var bottom_of_object = $(this).offset().top + $(this).outerHeight(); + var bottom_of_window = $(window).scrollTop() + $(window).height(); + /* If the object is completely visible in the window, fade it in */ + if (bottom_of_window + 100 > bottom_of_object) { + $(this).animate({'opacity':'1'}, 500); + $(this).removeClass('hideme'); + } + }); + hideScrollIfAllDivsAreVisible(); + }); + + var isHover = false; + $('#scrollImg').mouseover(function() { + isHover = true; + var interval = window.setInterval(function () { + var newPos = $(window).scrollTop() + 100; + $(window).scrollTop(newPos); + if (isHover == false) { + window.clearInterval(interval); + } + }, 200); + }); + + $('#scrollImg').mouseleave(function() { + isHover = false; + }); + + + //When some item is moved + $('.grid-stack').on('change', function (e, items) { + var widgets = []; + _.map($('.grid-stack .grid-stack-item:visible'), function (el) { + el = $(el); + var item = el.data('_gridstack_node'); + var idWidGet = el.data("indicator-id"); + /*if(favorite == actualDashId){ + favoriteData = 1; + } else { + favoriteData = 0; + }*/ + if (typeof idWidGet != "undefined") { + var widgetsObj = { + 'indicatorId': idWidGet, + 'x': item.x, + 'y': item.y, + 'width': item.width, + 'height': item.height <= 1 ? 2 : item.height + } + widgets.push(widgetsObj); + } + }); + + var favoriteDasbhoardId = $('.das-icon-selector.selected').parent().data('dashboard-id'); + if (favoriteDasbhoardId == null || favoriteDasbhoardId == 'undefined') {throw new Error ('No favorite dashboard detected');} + + if (widgets.length != 0) { + var dashboard = { + 'dashId': window.currentDashboardId, + 'dashFavorite': ((window.currentDashboardId == favoriteDasbhoardId) ? 1 : 0), + 'dashData': widgets + } + model.setPositionIndicator(dashboard); + } + }); + + $('body').on('click', '.das-icon-selector', function() { + var dashboardId = $(this).parent().data('dashboard-id'); + $('.das-icon-selector').removeClass("selected"); + $(this).addClass('selected'); + var dashboard = { + 'dashId': dashboardId, + 'dashFavorite': 1, + 'dashData': '' + } + model.setPositionIndicator(dashboard); + }); + + + /*-------------------------------clicks----------------------------*/ + $('body').on('click','.btn-compare', function() { + presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate()) + .done(function(indicatorsVM) { + fillIndicatorWidgets(indicatorsVM); + loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate()); + }); + }); + + $('#dashboardsList').on('click','.das-title-selector', function() { + var dashboardId = $(this).parent().data('dashboard-id'); + window.currentDashboardId = dashboardId; + 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; + }); + + $('#relatedDetailGridStack').on('click','.detail-button-selector', function() { + var detailId = $(this).data('detail-id'); + window.currentEntityData = {"entityId":$(this).data('detail-id'), + "indicatorId":$(this).data('indicator-id'), + "efficiencyIndexToShow":$(this).data('detail-index'), + "inefficiencyCostToShow":$(this).data('detail-cost-to-show'), + "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); + }); + }); + initialDraw(); +}); + +var hideScrollIfAllDivsAreVisible = function(){ + if ($('.hideme').length <= 0) { + $('#scrollImg').hide(); + } + else { + $('#scrollImg').show(); + } +} + +var selectedOrderOfDetailList = function () { + return ($('#sortListButton').hasClass('fa-chevron-up') ? "up" : "down"); +} + +var initialDraw = function () { + presenter.getUserDashboards(pageUserId) + .then(function(dashboardsVM) { + fillDashboardsList(dashboardsVM); + /**** window initialization with favorite dashboard*****/ + presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate()) + .done(function(indicatorsVM) { + fillIndicatorWidgets(indicatorsVM); + loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate()); + }); + }); +} + +var loadIndicator = function (indicatorId, initDate, endDate) { + var builder = new WidgetBuilder(); + window.currentIndicator = builder.getIndicatorLoadedById(indicatorId); + presenter.getIndicatorData(indicatorId, window.currentIndicator.type, initDate, endDate) + .done(function (viewModel) { + switch (window.currentIndicator.type) { + case "1010": + case "1030": + fillSpecialIndicatorFirstView(viewModel); + break; + case "1050": + fillStatusIndicatorFirstView(viewModel); + break; + default: + fillGeneralIndicatorFirstView(viewModel); + break; + } + }); +} + +var setIndicatorActiveMarker = function () { + $('.panel-footer').each (function () { + $(this).removeClass('panel-active'); + var indicatorId = $(this).parents('.ind-button-selector').data('indicator-id'); + if (window.currentIndicator.id == indicatorId) { + $(this).addClass('panel-active'); + } + }); +} + +var getFavoriteIndicator = function() { + var retval = (window.loadedIndicators.length > 0) + ? window.loadedIndicators[0] + : null; + for (key in window.loadedIndicators) { + var indicator = window.loadedIndicators[key]; + if (indicator.favorite == 1) { + retval = indicator; + } + } + if (retval==null) {throw new Error ('No favorites found.');} + return retval; +} + +var defaultInitDate = function() { + var date = new Date(); + var dateMonth = date.getMonth(); + var dateYear = date.getFullYear(); + var initDate = $('#year').val() + '-' + $('#month').val() + '-' + '01'; + return initDate; +} + +var defaultEndDate = function () { + var date = new Date(); + var dateMonth = date.getMonth(); + var dateYear = date.getFullYear(); + return dateYear + "-" + (dateMonth + 1) + "-30"; +} + +var fillDashboardsList = function (presenterData) { + if (presenterData == null || presenterData.length == 0) { + $('#dashboardsList').append(G_STRING['ID_NO_DATA_TO_DISPLAY']); + } + _.templateSettings.variable = "dashboard"; + var template = _.template ($("script.dashboardButtonTemplate").html()) + for (key in presenterData) { + var dashboard = presenterData[key]; + $('#dashboardsList').append(template(dashboard)); + if (dashboard.isFavorite == 1) { + window.currentDashboardId = dashboard.id; + $('#dashboardButton-' + dashboard.id) + .find('.das-icon-selector') + .addClass('selected'); + } + } + +}; + +var fillIndicatorWidgets = function (presenterData) { + var widgetBuilder = new WidgetBuilder(); + var grid = $('#indicatorsGridStack').data('gridstack'); + grid.remove_all(); + window.loadedIndicators = 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"); + } + }); +} + +var fillStatusIndicatorFirstView = function (presenterData) { + var widgetBuilder = new WidgetBuilder(); + var panel = $('#indicatorsDataGridStack').data('gridstack'); + panel.remove_all(); + $('#relatedDetailGridStack').data('gridstack').remove_all(); + + var $widget = widgetBuilder.buildStatusIndicatorFirstView(presenterData); + panel.add_widget($widget, 0, 15, 20, 4.7, true); + + var graphParams1 = { + canvas : { + containerId:'graph1', + width:300, + height:300, + stretch:true + }, + graph: { + allowDrillDown:false, + allowTransition:true, + showTip: true, + allowZoom: false, + gapWidth:0.2, + useShadows: true, + thickness: 30, + showLabels: true, + colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a'] + } + }; + + var graph1 = new PieChart(presenterData.graph1Data, graphParams1, null, null); + graph1.drawChart(); + + var graphParams2 = graphParams1; + graphParams2.canvas.containerId = "graph2"; + var graph2 = new PieChart(presenterData.graph2Data, graphParams2, null, null); + graph2.drawChart(); + var graphParams3 = graphParams1; + graphParams3.canvas.containerId = "graph3"; + var graph3 = new PieChart(presenterData.graph3Data, graphParams3, null, null); + graph3.drawChart(); + + var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(presenterData.id) + setIndicatorActiveMarker(); +} + +var fillStatusIndicatorFirstViewDetail = function(presenterData) { + var widgetBuilder = new WidgetBuilder(); + var gridDetail = $('#relatedDetailGridStack').data('gridstack'); + //gridDetail.remove_all(); + $.each(presenterData.dataList, function(index, dataItem) { + var $widget = widgetBuilder.buildStatusIndicatorFirstViewDetail(dataItem); + var x = (index % 2 == 0) ? 6 : 0; + gridDetail.add_widget($widget, x, 15, 6, 2, true); + }); + if (window.currentIndicator.type == "1010") { + $('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_PROCESS']); + } + if (window.currentIndicator.type == "1030") { + $('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_GROUPS']); + } + if (window.currentIndicator.type == "1050") { + $('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_PROCESS']); + } +} + +var fillSpecialIndicatorFirstView = function(presenterData) { + var widgetBuilder = new WidgetBuilder(); + var panel = $('#indicatorsDataGridStack').data('gridstack'); + panel.remove_all(); + $('#relatedDetailGridStack').data('gridstack').remove_all(); + + var $widget = widgetBuilder.buildSpecialIndicatorFirstView(presenterData); + panel.add_widget($widget, 0, 15, 20, 4.7, true); + var peiParams = { + canvas : { + containerId:'specialIndicatorGraph', + width:300, + height:300, + stretch:true + }, + graph: { + allowDrillDown:false, + allowTransition:true, + showTip: true, + allowZoom: false, + gapWidth:0.3, + useShadows: true, + thickness: 30, + showLabels: true, + colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a'] + } + }; + + var ueiParams = { + canvas : { + containerId:'specialIndicatorGraph', + width:500, + height:300, + stretch:true + }, + graph: { + allowDrillDown:false, + allowTransition:true, + axisX:{ showAxis: true, label: G_STRING.ID_YEAR }, + axisY:{ showAxis: true, label: "Q" }, + gridLinesX:false, + gridLinesY:true, + showTip: true, + allowZoom: false, + useShadows: true, + paddingTop: 50, + colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9'] + } + }; + + var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(presenterData.id) + + if (indicatorPrincipalData.type == "1010") { + var graph = new Pie3DChart(presenterData.dataToDraw, peiParams, null, null); + graph.drawChart(); + //the pie chart goes to much upwards,so a margin is added: + $('#specialIndicatorGraph').css('margin-top','60px'); + } + + if (indicatorPrincipalData.type == "1030") { + var graph = new BarChart(presenterData.dataToDraw, ueiParams, null, null); + graph.drawChart(); + } + + + this.fillSpecialIndicatorFirstViewDetail(presenter.orderDataList(presenterData.data, selectedOrderOfDetailList())); + setIndicatorActiveMarker(); +} + +var fillSpecialIndicatorFirstViewDetail = function (list) { + //presenterData = { id: "indId", efficiencyIndex: "0.11764706", efficiencyVariation: -0.08235294, + // inefficiencyCost: "-127.5000", inefficiencyCostToShow: -127, efficiencyIndexToShow: 0.12 + // data: {indicatorId, uid, name, averateTime...}, dataToDraw: [{datalabe, value}] } + var widgetBuilder = new WidgetBuilder(); + var gridDetail = $('#relatedDetailGridStack').data('gridstack'); + gridDetail.remove_all(); + + window.currentDetailList = list; + window.currentDetailFunction = fillSpecialIndicatorFirstViewDetail; + + $.each(list, function(index, dataItem) { + var $widget = widgetBuilder.buildSpecialIndicatorFirstViewDetail(dataItem); + var x = (index % 2 == 0) ? 6 : 0; + //the first 2 elements are not hidden + if (index < 2) { + $widget.removeClass("hideme"); + } + gridDetail.add_widget($widget, x, 15, 6, 2, true); + }); + if (window.currentIndicator.type == "1010") { + $('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_PROCESS']); + } + if (window.currentIndicator.type == "1030") { + $('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_GROUPS']); + } + hideScrollIfAllDivsAreVisible(); +} + +var fillSpecialIndicatorSecondView = function(presenterData) { + //presenterData= object {dataToDraw[], entityData[] //user/tasks data} + var widgetBuilder = new WidgetBuilder(); + var panel = $('#indicatorsDataGridStack').data('gridstack'); + panel.remove_all(); + var $widget = widgetBuilder.buildSpecialIndicatorSecondView(presenterData); + panel.add_widget($widget, 0, 15, 20, 4.7, true); + var detailParams = { + canvas : { + containerId:'specialIndicatorGraph', + width:300, + height:300, + stretch:true + }, + graph: { + allowTransition: false, + allowDrillDown: true, + showTip: true, + allowZoom: false, + useShadows: false, + gridLinesX: true, + gridLinesY: true, + area: {visible: false, css:"area"}, + axisX:{ showAxis: true, label: G_STRING.ID_USERS }, + axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS }, + showErrorBars: true + + } + }; + + var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(window.currentEntityData.indicatorId); + + if (window.currentIndicator.type == "1010") { + var graph = new BarChart(presenterData.dataToDraw, detailParams, null, null); + graph.drawChart(); + } + + if (window.currentIndicator.type == "1030") { + var graph = new BarChart(presenterData.dataToDraw, detailParams, null, null); + graph.drawChart(); + } + this.fillSpecialIndicatorSecondViewDetail(presenter.orderDataList(presenterData.entityData, selectedOrderOfDetailList())); +} + +var fillSpecialIndicatorSecondViewDetail = function (list) { + //presenterData = { entityData: Array[{name,uid,inefficiencyCost, + // inefficiencyIndex, deviationTime, + // averageTime}], + // dataToDraw: Array[{datalabel, value}] } + var widgetBuilder = new WidgetBuilder(); + var gridDetail = $('#relatedDetailGridStack').data('gridstack'); + gridDetail.remove_all(); + + window.currentDetailList = list; + window.currentDetailFunction = fillSpecialIndicatorSecondViewDetail; + + $.each(list, function(index, dataItem) { + var $widget = widgetBuilder.buildSpecialIndicatorSecondViewDetail(dataItem); + var x = (index % 2 == 0) ? 6 : 0; + //the first 2 elements are not hidden + if (index < 2) { + $widget.removeClass("hideme"); + } + gridDetail.add_widget($widget, x, 15, 6, 2, true); + }); + + if (window.currentIndicator.type == "1010") { + $('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_TASKS']); + } + if (window.currentIndicator.type == "1030") { + $('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_USERS']); + } + hideScrollIfAllDivsAreVisible(); +} + +var fillGeneralIndicatorFirstView = function (presenterData) { + var widgetBuilder = new WidgetBuilder(); + var panel = $('#indicatorsDataGridStack').data('gridstack'); + panel.remove_all(); + $('#relatedDetailGridStack').data('gridstack').remove_all(); + + var $widget = widgetBuilder.buildGeneralIndicatorFirstView(presenterData); + panel.add_widget($widget, 0, 15, 20, 4.7, true); + + $('#relatedLabel').find('h3').text(''); + + var generalLineParams1 = { + canvas : { + containerId:'generalGraph1', + width:300, + height:300, + stretch:true + }, + graph: { + allowTransition: false, + allowDrillDown: true, + showTip: true, + allowZoom: false, + useShadows: false, + gridLinesX: true, + gridLinesY: true, + area: {visible: false, css:"area"}, + axisX:{ showAxis: true, label: G_STRING.ID_PROCESS_TASKS }, + axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS }, + showErrorBars: false + } + }; + + var generalLineParams2 = { + canvas : { + containerId:'generalGraph2', + width:300, + height:300, + stretch:true + }, + graph: { + allowTransition: false, + allowDrillDown: true, + showTip: true, + allowZoom: false, + useShadows: false, + gridLinesX: true, + gridLinesY: true, + area: {visible: false, css:"area"}, + axisX:{ showAxis: true, label: G_STRING.ID_PROCESS_TASKS }, + axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS }, + showErrorBars: false + } + }; + + var generalBarParams1 = { + canvas : { + containerId:'generalGraph1', + width:300, + height:300, + stretch:true + }, + graph: { + allowDrillDown:false, + allowTransition:true, + axisX:{ showAxis: true, label: G_STRING.ID_YEAR }, + axisY:{ showAxis: true, label: "Q" }, + gridLinesX:false, + gridLinesY:true, + showTip: true, + allowZoom: false, + useShadows: true, + paddingTop: 50, + colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9'] + } + }; + + var generalBarParams2 = { + canvas : { + containerId:'generalGraph2', + width:300, + height:300, + stretch:true + }, + graph: { + allowDrillDown:false, + allowTransition:true, + axisX:{ showAxis: true, label: G_STRING.ID_YEAR }, + axisY:{ showAxis: true, label: "Q" }, + gridLinesX:false, + gridLinesY:true, + showTip: true, + allowZoom: false, + useShadows: true, + paddingTop: 50, + colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9'] + } + }; + + var graph1 = null; + if (presenterData.graph1Type == '10') { + generalBarParams1.graph.axisX.label = presenterData.graph1XLabel; + generalBarParams1.graph.axisY.label = presenterData.graph1YLabel; + graph1 = new BarChart(presenterData.graph1Data, generalBarParams1, null, null); + } else { + generalLineParams1.graph.axisX.label = presenterData.graph1XLabel; + generalLineParams1.graph.axisY.label = presenterData.graph1YLabel; + graph1 = new LineChart(presenterData.graph1Data, generalLineParams1, null, null); + } + graph1.drawChart(); + + var graph2 = null; + if (presenterData.graph2Type == '10') { + generalBarParams2.graph.axisX.label = presenterData.graph2XLabel; + generalBarParams2.graph.axisY.label = presenterData.graph2YLabel; + graph2 = new BarChart(presenterData.graph2Data, generalBarParams2, null, null); + } else { + generalLineParams2.graph.axisX.label = presenterData.graph2XLabel; + generalLineParams2.graph.axisY.label = presenterData.graph2YLabel; + graph2 = new LineChart(presenterData.graph2Data, generalLineParams2, null, null); + } + graph2.drawChart(); + + setIndicatorActiveMarker(); +} + +var animateProgress = function (indicatorItem, widget){ + var getRequestAnimationFrame = function () { + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function ( callback ){ + window.setTimeout(enroute, 1 / 60 * 1000); + }; + }; + + var fpAnimationFrame = getRequestAnimationFrame(); + var i = 0; + var j = 0; + + var indicator = indicatorItem; + var animacion = function () { + var intComparative = parseInt(indicator.comparative); + var divId = "#indicatorButton" + indicator.id; + var $valueLabel = widget + .find('.ind-value-selector'); + var $progressBar = widget + .find('.ind-progress-selector'); + + if (!($valueLabel.length > 0)) {throw new Error ('"No ind-value-selector found for " + divId');} + this.helper.assert($progressBar.length > 0, "No ind-progress-selector found for " + divId); + $progressBar.attr('aria-valuemax', intComparative); + var indexToPaint = Math.min(indicator.value * 100 / intComparative, 100); + + if (i <= indexToPaint) { + $progressBar.css('width', i+'%').attr('aria-valuenow', i); + i++; + fpAnimationFrame(animacion); + } + + if(j <= indicator.value){ + $valueLabel.text(j + "%"); + j++; + fpAnimationFrame(animacion); + } + + } + fpAnimationFrame(animacion); +}; + +/*var dashboardButtonTemplate = '
    \ + \ + \ +
    ';*/ + + + diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index df4224e1e..f3af8eb91 100755 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -908,7 +908,7 @@ try { $daysSelected = "selected = 'selected'"; } - $sAux = ''; @@ -921,7 +921,7 @@ try { $calendarSelected = "selected = 'selected'"; } - $sAux = ''; diff --git a/workflow/engine/methods/cases/pmDynaform.php b/workflow/engine/methods/cases/pmDynaform.php index 97041fb70..7cbab53dd 100644 --- a/workflow/engine/methods/cases/pmDynaform.php +++ b/workflow/engine/methods/cases/pmDynaform.php @@ -1,6 +1,7 @@ $DYN_UID)); $a->printPmDynaform(); diff --git a/workflow/engine/methods/setup/setupSchemas/triggerFillReportByProcess.sql b/workflow/engine/methods/setup/setupSchemas/triggerFillReportByProcess.sql index eb3dc4808..e62d919e3 100644 --- a/workflow/engine/methods/setup/setupSchemas/triggerFillReportByProcess.sql +++ b/workflow/engine/methods/setup/setupSchemas/triggerFillReportByProcess.sql @@ -42,7 +42,7 @@ GROUP BY APPLICATION.PRO_UID; UPDATE PRO_REPORTING SET PRO_REPORTING.CONFIGURED_PROCESS_TIME = ( - SELECT SUM(if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*8), TASK.TAS_DURATION)) + SELECT SUM(if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*24), TASK.TAS_DURATION)) FROM TASK WHERE PRO_REPORTING.PRO_UID = TASK.PRO_UID ); diff --git a/workflow/engine/methods/setup/setupSchemas/triggerFillReportByUser.sql b/workflow/engine/methods/setup/setupSchemas/triggerFillReportByUser.sql index 9ffb5b5ea..114565856 100644 --- a/workflow/engine/methods/setup/setupSchemas/triggerFillReportByUser.sql +++ b/workflow/engine/methods/setup/setupSchemas/triggerFillReportByUser.sql @@ -55,7 +55,7 @@ UPDATE USR_REPORTING INNER JOIN TASK ON USR_REPORTING.TAS_UID = TASK.TAS_UID -SET USR_REPORTING.CONFIGURED_TASK_TIME = if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*8), TASK.TAS_DURATION) +SET USR_REPORTING.CONFIGURED_TASK_TIME = if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*24), TASK.TAS_DURATION) diff --git a/workflow/engine/methods/tracker/tracker_Show.php b/workflow/engine/methods/tracker/tracker_Show.php index 652b24949..5259a7447 100755 --- a/workflow/engine/methods/tracker/tracker_Show.php +++ b/workflow/engine/methods/tracker/tracker_Show.php @@ -54,11 +54,27 @@ switch ($_GET['CTO_TYPE_OBJ']) { $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PRINT_PREVIEW'] = '#'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PRINT_PREVIEW_ACTION'] = 'tracker_PrintView?CTO_UID_OBJ=' . $_GET['CTO_UID_OBJ'] . '&CTO_TYPE_OBJ=PRINT_PREVIEW'; $_SESSION['CTO_UID_OBJ'] = $_GET['CTO_UID_OBJ']; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_GET['CTO_UID_OBJ'], '', $Fields['APP_DATA'], '', '', 'view' ); - G::RenderPage( 'publish' ); - break; + $dynaForm = new Dynaform(); + $arrayDynaFormData = $dynaForm->Load($_GET["CTO_UID_OBJ"]); + + if (isset($arrayDynaFormData["DYN_VERSION"]) && $arrayDynaFormData["DYN_VERSION"] == 2) { + G::LoadClass("pmDynaform"); + + $Fields["PRO_UID"] = $_SESSION["PROCESS"]; + $Fields["CURRENT_DYNAFORM"] = $_GET["CTO_UID_OBJ"]; + + $pmDynaForm = new pmDynaform($Fields); + + if ($pmDynaForm->isResponsive()) { + $pmDynaForm->printViewWithoutSubmit(); + } + } else { + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent("dynaform", "xmlform", $_SESSION["PROCESS"] . "/" . $_GET["CTO_UID_OBJ"], "", $Fields["APP_DATA"], "", "", "view"); + G::RenderPage("publish"); + } + break; case 'INPUT_DOCUMENT': G::LoadClass( 'case' ); $oCase = new Cases(); diff --git a/workflow/engine/skinEngine/neoclassic/css/loginStyle.css b/workflow/engine/skinEngine/neoclassic/css/loginStyle.css index bcf5c1cb2..f6e2b7fe2 100644 --- a/workflow/engine/skinEngine/neoclassic/css/loginStyle.css +++ b/workflow/engine/skinEngine/neoclassic/css/loginStyle.css @@ -1,9 +1,18 @@ /* * LOGIN PM3 STYLES */ + +@font-face { + font-family: "Chivo"; + font-style: normal; + font-weight: normal; + src: local("?"), url("/fonts/Chivo-Regular.ttf") format("truetype"); + } body.login { background: url("/images/backgroundpm3.jpg") repeat scroll 0 0 / cover rgba(0, 0, 0, 0); - //background-position-y: -30px; + //background-position-y: -30px; + font-family: "Chivo",sans-serif; + height: 100%; } .vertical-offset-100 { @@ -48,7 +57,8 @@ img.img-responsive { .module_app_input___gray { - background-color: #fff; + font-family: "Chivo",sans-serif; + background-color: #fff; background-image: none; border: 1px solid #ccc; border-radius: 4px; @@ -71,9 +81,11 @@ img.img-responsive { color: #555; display: block; font-size: 14px; - height: 45px; + //height: 45px; + box-sizing: border-box; + //padding-top: 12px; line-height: 1.42857; - padding: 9px 12px; + //padding: 9px 12px; transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s; width: 100%; } @@ -82,6 +94,7 @@ img.img-responsive { box-sizing: border-box; color: #444; font-family: "Open Sans",Arial,Helvetica,sans-serif; + //font-family: "Chivo",sans-serif; font-size: 16px; height: 45px; padding: 10px; @@ -89,6 +102,12 @@ img.img-responsive { margin-bottom: 6px; } + +.form-signin .module_app_input___gray:-ms-input-placeholder { + font-family: "Open Sans",Arial,Helvetica,sans-serif; + color:#999; + } + .module_app_input___gray::-moz-placeholder { color: #999; opacity: 1; @@ -159,7 +178,7 @@ p { font-weight: 700; //transition: all 0.3s ease-in-out 0s; max-width: 400px; - filter:none; + filter:none; } .button-login-success:hover{ @@ -211,13 +230,10 @@ p { font-size: 11px; } -.footer-login .content{ +.footer-login span{ color: white; font-weight: 900; -} - -.footer-login{ - text-align: center; + font-size: 12px; } .login_result span{ @@ -227,6 +243,7 @@ p { .login .module_app_inputFailed___gray{ + font-family: "Chivo",sans-serif; background-color: #fff; background-image: none; border: 1px solid #ccc; @@ -241,4 +258,29 @@ p { transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s; width: 100%; border:1px solid #e14333; -} \ No newline at end of file +} + +.page-wrap{ + height: auto; + margin: 0 auto -60px; + min-height: 95%; + padding: 0 0 60px; +} + +.page-wrap:after{ + width: 100%; + display:block; + clear:both; +} + +.footer-login{ + text-align: center; + height: auto; + margin: -0px auto 0; +} + +#form[FORGOT_PASWORD_LINK]{ + font-family: Chivo; + font-size: 14px; + padding-top: 10px; +} diff --git a/workflow/engine/skinEngine/neoclassic/layout.html b/workflow/engine/skinEngine/neoclassic/layout.html index af628788d..a2996d5ba 100644 --- a/workflow/engine/skinEngine/neoclassic/layout.html +++ b/workflow/engine/skinEngine/neoclassic/layout.html @@ -78,10 +78,8 @@ {else} - - + +
    @@ -102,8 +100,13 @@
    - + {/if} diff --git a/workflow/engine/skinEngine/skinEngine.php b/workflow/engine/skinEngine/skinEngine.php index fd3d6a9da..e6a7290a7 100755 --- a/workflow/engine/skinEngine/skinEngine.php +++ b/workflow/engine/skinEngine/skinEngine.php @@ -377,8 +377,8 @@ class SkinEngine if (strpos($_SERVER['REQUEST_URI'], '/login/login') !== false) { $freeOfChargeText = ""; if (! defined('SKIP_FREE_OF_CHARGE_TEXT')) - $freeOfChargeText = "Supplied free of charge with no support, certification, warranty,
    maintenance nor indemnity by Colosa and its Certified Partners."; - if(class_exists('pmLicenseManager')) $freeOfChargeText=""; + $freeOfChargeText = "Supplied free of charge with no support, certification, warranty,
    maintenance nor indemnity by Processmaker and its Certified Partners."; + if(file_exists(PATH_CLASSES."class.pmLicenseManager.php")) $freeOfChargeText=""; $fileFooter = PATH_SKINS . SYS_SKIN . PATH_SEP . 'footer.html'; if (file_exists($fileFooter)) { @@ -392,7 +392,7 @@ class SkinEngine if (file_exists($fileFooter)) { $footer .= file_get_contents($fileFooter); } else { - $footer .= "
    Copyright © 2000-" . date('Y') . " ProcessMaker Inc. All rights reserved.
    $freeOfChargeText " . "

    "; + $footer .= "$freeOfChargeText
    Copyright © 2000-" . date('Y') . " ProcessMaker Inc. All rights reserved.
    " . "

    "; } } } @@ -505,7 +505,7 @@ class SkinEngine if (file_exists($fileFooter)) { $footer .= file_get_contents($fileFooter); } else { - $footer .= "
    Copyright © 2000-" . date('Y') . " ProcessMaker Inc. All rights reserved.
    $freeOfChargeText " . "

    "; + $footer .= "$freeOfChargeText
    Copyright © 2000-" . date('Y') . " ProcessMaker Inc. All rights reserved.
    " . "

    "; } } } @@ -698,8 +698,8 @@ class SkinEngine if (strpos($_SERVER['REQUEST_URI'], '/login/login') !== false) { $freeOfChargeText = ""; if (! defined('SKIP_FREE_OF_CHARGE_TEXT')) - $freeOfChargeText = "Supplied free of charge with no support, certification, warranty, maintenance nor indemnity by Colosa and its Certified Partners."; - if(class_exists('pmLicenseManager')) $freeOfChargeText=""; + $freeOfChargeText = "Supplied free of charge with no support, certification, warranty, maintenance nor indemnity by ProcessMaker and its Certified Partners."; + if(file_exists(PATH_CLASSES."class.pmLicenseManager.php")) $freeOfChargeText=""; $fileFooter = PATH_SKINS . SYS_SKIN . PATH_SEP . 'footer.html'; if (file_exists($fileFooter)) { @@ -713,7 +713,7 @@ class SkinEngine if (file_exists($fileFooter)) { $footer .= file_get_contents($fileFooter); } else { - $footer .= " $freeOfChargeText
    Copyright © 2000-" . date('Y') . " ProcessMaker Inc. All rights reserved.
    " . "

    "; + $footer .= "$freeOfChargeText
    Copyright © 2000-" . date('Y') . " ProcessMaker Inc. All rights reserved.
    " . "

    "; } } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ReportingIndicators.php b/workflow/engine/src/ProcessMaker/BusinessModel/ReportingIndicators.php index 37bd2b45b..2491b49cb 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ReportingIndicators.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ReportingIndicators.php @@ -18,7 +18,7 @@ class ReportingIndicators * * return decimal value */ - public function getPeiCompleteData($indicatorUid, $measureDate, $compareDate, $language) + public function getPeiCompleteData($indicatorUid, $compareDate, $measureDate, $language) { G::loadClass('indicatorsCalculator'); $calculator = new \IndicatorsCalculator(); @@ -30,7 +30,10 @@ class ReportingIndicators $peiCost = current(reset($calculator->peiCostHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE))); $peiCompare = current(reset($calculator->peiHistoric($processesId, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE))); - $retval = array("efficiencyIndex" => $peiValue, + $retval = array( + "id" => $indicatorUid, + "efficiencyIndex" => $peiValue, + "efficiencyIndexCompare" => $peiCompare, "efficiencyVariation" => ($peiValue-$peiCompare), "inefficiencyCost" => $peiCost, "data"=>$processes); @@ -47,32 +50,22 @@ class ReportingIndicators * * return decimal value */ - public function getUeiCompleteData($indicatorUid, $measureDate, $compareDate, $language) + public function getUeiCompleteData($indicatorUid, $compareDate, $measureDate,$language) { G::loadClass('indicatorsCalculator'); $calculator = new \IndicatorsCalculator(); $groups = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language); - $groupIds = array(); - foreach($groups as $p) { - array_push($groupIds, $p['uid']); - } - - if (sizeof($groupIds) == 0) { - $groupIds = null; - } - //TODO think what if each indicators has a group or user subset assigned. Now are all $ueiValue = current(reset($calculator->ueiHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE))); $arrCost = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language); - $ueiCost = (sizeof($arrCost) > 0) - ? $arrCost[0]['inefficiencyCost'] - : null; - + $ueiCost = current(reset($calculator->ueiCostHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE))); $ueiCompare = current(reset($calculator->ueiHistoric(null, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE))); - $retval = array("efficiencyIndex" => $ueiValue, + $retval = array( + "id" => $indicatorUid, + "efficiencyIndex" => $ueiValue, "efficiencyVariation" => ($ueiValue-$ueiCompare), "inefficiencyCost" => $ueiCost, "data"=>$groups); @@ -296,5 +289,27 @@ class ReportingIndicators ); return $returnValue; } + + /** + * Get list status indicator + * + * @access public + * @param array $options, Data for list + * @return array + * + * @author Marco Antonio Nina + * @copyright Colosa - Bolivia + */ + public function getStatusIndicator($options = array()) + { + Validator::isArray($options, '$options'); + + $usrUid = isset( $options["usrUid"] ) ? $options["usrUid"] : ""; + + G::loadClass('indicatorsCalculator'); + $calculator = new \IndicatorsCalculator(); + $result = $calculator->statusIndicator($usrUid); + return $result; + } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Task.php b/workflow/engine/src/ProcessMaker/BusinessModel/Task.php index d6b6c31f2..d2ac8fba8 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Task.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Task.php @@ -321,7 +321,7 @@ class Task } //Validating TAS_TRANSFER_FLY value - if ($arrayProperty["TAS_TRANSFER_FLY"] == "TRUE") { + if ($arrayProperty["TAS_TRANSFER_FLY"] == "FALSE") { if (!isset($arrayProperty["TAS_DURATION"])) { throw (new \Exception("Invalid value specified for 'tas_duration'")); } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php index fc4d5b237..8e0e25ffd 100755 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php @@ -129,10 +129,13 @@ class Variable $cnn = \Propel::getConnection("workflow"); try { $variable = \ProcessVariablesPeer::retrieveByPK($variableUid); + $dbConnection = \DbSourcePeer::retrieveByPK($variable->getVarDbconnection(), $variable->getPrjUid()); + $oldVariable = array( "VAR_NAME" => $variable->getVarName(), "VAR_FIELD_TYPE" => $variable->getVarFieldType(), "VAR_DBCONNECTION" => $variable->getVarDbconnection(), + "VAR_DBCONNECTION_LABEL" => $dbConnection !== null ? '[' . $dbConnection->getDbsServer() . ':' . $dbConnection->getDbsPort() . '] ' . $dbConnection->getDbsType() . ': ' . $dbConnection->getDbsDatabaseName() : 'PM Database', "VAR_SQL" => $variable->getVarSql(), "VAR_ACCEPTED_VALUES" => $variable->getVarAcceptedValues() ); @@ -170,10 +173,12 @@ class Variable $variable->save(); $cnn->commit(); //update dynaforms + $dbConnection = \DbSourcePeer::retrieveByPK($variable->getVarDbconnection(), $variable->getPrjUid()); $newVariable = array( "VAR_NAME" => $variable->getVarName(), "VAR_FIELD_TYPE" => $variable->getVarFieldType(), "VAR_DBCONNECTION" => $variable->getVarDbconnection(), + "VAR_DBCONNECTION_LABEL" => $dbConnection !== null ? '[' . $dbConnection->getDbsServer() . ':' . $dbConnection->getDbsPort() . '] ' . $dbConnection->getDbsType() . ': ' . $dbConnection->getDbsDatabaseName() : 'PM Database', "VAR_SQL" => $variable->getVarSql(), "VAR_ACCEPTED_VALUES" => $variable->getVarAcceptedValues() ); @@ -265,9 +270,14 @@ class Variable $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NULL); $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_DEFAULT); $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_ACCEPTED_VALUES); + $criteria->addSelectColumn(\DbSourcePeer::DBS_SERVER); + $criteria->addSelectColumn(\DbSourcePeer::DBS_PORT); + $criteria->addSelectColumn(\DbSourcePeer::DBS_DATABASE_NAME); + $criteria->addSelectColumn(\DbSourcePeer::DBS_TYPE); $criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL); $criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid, \Criteria::EQUAL); + $criteria->addJoin(\ProcessVariablesPeer::VAR_DBCONNECTION, \DbSourcePeer::DBS_UID, \Criteria::LEFT_JOIN); $rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria); @@ -283,7 +293,8 @@ class Variable 'var_field_type' => $aRow['VAR_FIELD_TYPE'], 'var_field_size' => (int)$aRow['VAR_FIELD_SIZE'], 'var_label' => $aRow['VAR_LABEL'], - 'var_dbconnection' => $aRow['VAR_DBCONNECTION'], + 'var_dbconnection' => $aRow['VAR_DBCONNECTION'] === 'none' ? 'workflow' : $aRow['VAR_DBCONNECTION'], + 'var_dbconnection_label' => $aRow['DBS_SERVER'] !== null ? '[' . $aRow['DBS_SERVER'] . ':' . $aRow['DBS_PORT'] . '] ' . $aRow['DBS_TYPE'] . ': ' . $aRow['DBS_DATABASE_NAME'] : 'PM Database', 'var_sql' => $aRow['VAR_SQL'], 'var_null' => (int)$aRow['VAR_NULL'], 'var_default' => $aRow['VAR_DEFAULT'], @@ -326,8 +337,13 @@ class Variable $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NULL); $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_DEFAULT); $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_ACCEPTED_VALUES); + $criteria->addSelectColumn(\DbSourcePeer::DBS_SERVER); + $criteria->addSelectColumn(\DbSourcePeer::DBS_PORT); + $criteria->addSelectColumn(\DbSourcePeer::DBS_DATABASE_NAME); + $criteria->addSelectColumn(\DbSourcePeer::DBS_TYPE); $criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL); + $criteria->addJoin(\ProcessVariablesPeer::VAR_DBCONNECTION, \DbSourcePeer::DBS_UID, \Criteria::LEFT_JOIN); $rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria); @@ -343,7 +359,8 @@ class Variable 'var_field_type' => $aRow['VAR_FIELD_TYPE'], 'var_field_size' => (int)$aRow['VAR_FIELD_SIZE'], 'var_label' => $aRow['VAR_LABEL'], - 'var_dbconnection' => $aRow['VAR_DBCONNECTION'], + 'var_dbconnection' => $aRow['VAR_DBCONNECTION'] === 'none' ? 'workflow' : $aRow['VAR_DBCONNECTION'], + 'var_dbconnection_label' => $aRow['DBS_SERVER'] !== null ? '[' . $aRow['DBS_SERVER'] . ':' . $aRow['DBS_PORT'] . '] ' . $aRow['DBS_TYPE'] . ': ' . $aRow['DBS_DATABASE_NAME'] : 'PM Database', 'var_sql' => $aRow['VAR_SQL'], 'var_null' => (int)$aRow['VAR_NULL'], 'var_default' => $aRow['VAR_DEFAULT'], @@ -690,4 +707,3 @@ class Variable } } } - diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php index 902e075e8..0235e922c 100755 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php @@ -1384,10 +1384,6 @@ class BpmnWorkflow extends Project\Bpmn $activity = $bwp->getActivity($activityData["ACT_UID"]); - if ($activity["BOU_CONTAINER"] != $activityData["BOU_CONTAINER"]) { - $activity = null; - } - if ($forceInsert || is_null($activity)) { if ($generateUid) { //Generate and update UID diff --git a/workflow/engine/src/ProcessMaker/Services/Api/ReportingIndicators.php b/workflow/engine/src/ProcessMaker/Services/Api/ReportingIndicators.php index 3df2ef4d3..23a5190c9 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/ReportingIndicators.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/ReportingIndicators.php @@ -71,223 +71,6 @@ class ReportingIndicators extends Api } } -// /** -// * Returns the aggregate Efficiency of a employee or set of employees -// * -// * @param string $employee_list {@from path} -// * @param string $init_date {@from path} -// * @param string $end_date {@from path} -// * @return array -// * -// * @url GET /employee-efficiency-index -// */ -// public function doGetEmployeeEfficiencyIndex($employee_list, $init_date, $end_date) -// { -// try { -// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); -// $listArray = (strlen($employee_list) > 1) -// ? $listArray = explode(',', $employee_list) -// : null; -// $response = $indicatorsObj->getEmployeeEfficiencyIndex($listArray, -// new \DateTime($init_date), -// new \DateTime($end_date)); -// return $response; -// } catch (\Exception $e) { -// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -// } -// } -// -// /** -// * Lists tasks of a employee and it's statistics (efficiency, average times, etc.) -// * -// * @param string $employee_list {@from path} -// * @param string $init_date {@from path} -// * @param string $end_date {@from path} -// * @param string $language {@from path} -// * @return array -// * -// * @url GET /employee-tasks -// */ -// public function doGetEmployeeTasksInfo($employee_list, $init_date, $end_date, $language) -// { -// if ($employee_list == null || strlen($employee_list) <= 1) -// throw new InvalidArgumentException ('employee_list must have at least a value', 0); -// -// try { -// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); -// $listArray = $listArray = explode(',', $employee_list); -// $response = $indicatorsObj->getEmployeeTasksInfoList($listArray, -// new \DateTime($init_date), -// new \DateTime($end_date), -// $language); -// return $response; -// } catch (\Exception $e) { -// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -// } -// } -// -// /** -// * Returns the percent of Cases with Overdue time -// * -// * @param string $$process_list {@from path} -// * @param string $init_date {@from path} -// * @param string $end_date {@from path} -// * @return array -// * -// * @url GET /percent-overdue-cases -// */ -// public function doGetPercentOverdueByProcess($process_list, $init_date, $end_date) -// { -// try { -// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); -// $listArray = (strlen($process_list) > 1) -// ? $listArray = explode(',', $process_list) -// : null; -// $response = $indicatorsObj->getPercentOverdueCasesByProcess($listArray, -// new \DateTime($init_date), -// new \DateTime($end_date)); -// return $response; -// } catch (\Exception $e) { -// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -// } -// } -// -// /** -// * Returns the percent of Cases with Overdue time with the selected periodicity -// * -// * @param string $$process_list {@from path} -// * @param string $init_date {@from path} -// * @param string $end_date {@from path} -// * @param string $periodicity {@from path} -// * @return array -// * -// * @url GET /percent-overdue-cases-history -// */ -// public function doGetPercentOverdueByProcessHistory($process_list, $init_date, $end_date, $periodicity) -// { -// try { -// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); -// $listArray = (strlen($process_list) > 1) -// ? $listArray = explode(',', $process_list) -// : null; -// $response = $indicatorsObj->getPercentOverdueCasesByProcessHistory($listArray, -// new \DateTime($init_date), -// new \DateTime($end_date), -// $periodicity); -// return $response; -// } catch (\Exception $e) { -// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -// } -// } -// -// /** -// * Returns the total of Cases with New time -// * -// * @param string $$process_list {@from path} -// * @param string $init_date {@from path} -// * @param string $end_date {@from path} -// * @return array -// * -// * @url GET /total-new-cases -// */ -// public function doGetTotalNewByProcess($process_list, $init_date, $end_date) -// { -// try { -// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); -// $listArray = (strlen($process_list) > 1) -// ? $listArray = explode(',', $process_list) -// : null; -// $response = $indicatorsObj->getPercentNewCasesByProcess($listArray, -// new \DateTime($init_date), -// new \DateTime($end_date)); -// return $response; -// } catch (\Exception $e) { -// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -// } -// } -// -// /** -// * Returns the total of Cases with New time with the selected periodicity -// * -// * @param string $$process_list {@from path} -// * @param string $init_date {@from path} -// * @param string $end_date {@from path} -// * @param string $periodicity {@from path} -// * @return array -// * -// * @url GET /total-new-cases-history -// */ -// public function doGetTotalNewByProcessHistory($process_list, $init_date, $end_date, $periodicity) -// { -// try { -// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); -// $listArray = (strlen($process_list) > 1) -// ? $listArray = explode(',', $process_list) -// : null; -// $response = $indicatorsObj->getPercentNewCasesByProcessHistory($listArray, -// new \DateTime($init_date), -// new \DateTime($end_date), -// $periodicity); -// return $response; -// } catch (\Exception $e) { -// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -// } -// } -// -// /** -// * Returns the total of Cases with Completed time -// * -// * @param string $$process_list {@from path} -// * @param string $init_date {@from path} -// * @param string $end_date {@from path} -// * @return array -// * -// * @url GET /total-completed-cases -// */ -// public function doGetTotalCompletedByProcess($process_list, $init_date, $end_date) -// { -// try { -// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); -// $listArray = (strlen($process_list) > 1) -// ? $listArray = explode(',', $process_list) -// : null; -// $response = $indicatorsObj->getPercentCompletedCasesByProcess($listArray, -// new \DateTime($init_date), -// new \DateTime($end_date)); -// return $response; -// } catch (\Exception $e) { -// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -// } -// } -// -// /** -// * Returns the total of Cases with Completed time with the selected periodicity -// * -// * @param string $$process_list {@from path} -// * @param string $init_date {@from path} -// * @param string $end_date {@from path} -// * @param string $periodicity {@from path} -// * @return array -// * -// * @url GET /total-completed-cases-history -// */ -// public function doGetTotalCompletedByProcessHistory($process_list, $init_date, $end_date, $periodicity) -// { -// try { -// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); -// $listArray = (strlen($process_list) > 1) -// ? $listArray = explode(',', $process_list) -// : null; -// $response = $indicatorsObj->getPercentCompletedCasesByProcessHistory($listArray, -// new \DateTime($init_date), -// new \DateTime($end_date), -// $periodicity); -// return $response; -// } catch (\Exception $e) { -// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -// } -// } -// /** * Returns the total of Cases with Completed time with the selected periodicity * @@ -299,7 +82,7 @@ class ReportingIndicators extends Api * * @url GET /process-efficiency-data */ - public function doGetProcessEficciencyData($indicator_uid, $measure_date, $compare_date, $language) + public function doGetProcessEficciencyData($indicator_uid, $compare_date, $measure_date, $language) { try { $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); @@ -324,7 +107,7 @@ class ReportingIndicators extends Api * * @url GET /employee-efficiency-data */ - public function doGetEmployeeEficciencyData($indicator_uid, $measure_date, $compare_date, $language) + public function doGetEmployeeEficciencyData($indicator_uid, $compare_date, $measure_date, $language) { try { $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); @@ -390,6 +173,29 @@ class ReportingIndicators extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } + + /** + * Get list Status indicator + * + * @return array + * + * @author Marco Antonio Nina + * @copyright Colosa - Bolivia + * + * @url GET /status-indicator + */ + public function doGetStatusIndicator() { + try { + $options['usrUid'] = $this->getUserId(); + + $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); + $response = $indicatorsObj->getStatusIndicator($options); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + } diff --git a/workflow/engine/src/ProcessMaker/Services/OAuth2/PmPdo.php b/workflow/engine/src/ProcessMaker/Services/OAuth2/PmPdo.php index dd1573aea..966b4b05a 100644 --- a/workflow/engine/src/ProcessMaker/Services/OAuth2/PmPdo.php +++ b/workflow/engine/src/ProcessMaker/Services/OAuth2/PmPdo.php @@ -175,9 +175,11 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface, { $access_token = new \OauthAccessTokens(); $access_token->load($token); + $stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE ACCESS_TOKEN = :token', $this->config['access_token_table'])); $stmt->execute(compact('token')); - $stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE EXPIRES>%s', $this->config['refresh_token_table'], "'".Date('Y-m-d H:i:s')."'")); + + $stmt = $this->db->prepare(sprintf("DELETE FROM %s WHERE EXPIRES < %s", $this->config["refresh_token_table"], "'" . date("Y-m-d H:i:s") . "'")); return $stmt->execute(compact('token')); } diff --git a/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php b/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php index a97727741..8276c1d46 100644 --- a/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php +++ b/workflow/engine/src/ProcessMaker/Services/OAuth2/Server.php @@ -68,7 +68,10 @@ class Server implements iAuthenticate $this->server->addGrantType(new \ProcessMaker\Services\OAuth2\PmClientCredentials($this->storage)); // Add the "Refresh token" grant type - $this->server->addGrantType(new \OAuth2\GrantType\RefreshToken($this->storage)); + $this->server->addGrantType(new \OAuth2\GrantType\RefreshToken( + $this->storage, + array("always_issue_new_refresh_token" => true) + )); // create some users in memory //$users = array('bshaffer' => array('password' => 'brent123', 'first_name' => 'Brent', 'last_name' => 'Shaffer')); @@ -261,7 +264,9 @@ class Server implements iAuthenticate if ($returnResponse) { return $response; } else { - die($response->send()); + $response->send(); + + exit(0); } } @@ -279,9 +284,11 @@ class Server implements iAuthenticate if ($request == null) { $request = \OAuth2\Request::createFromGlobals(); } - $response = $this->server->handleTokenRequest($request); + + $response = $this->server->handleTokenRequest($request); //Set/Get token //PmPdo->setAccessToken() $token = $response->getParameters(); + if (array_key_exists('access_token', $token) && array_key_exists('refresh_token', $token) ) { @@ -309,17 +316,9 @@ class Server implements iAuthenticate if ($returnResponse) { return $response; } else { - if ($response->getStatusCode() == 400) { - $msg = $response->getParameter("error_description", ""); - $msg = ($msg != "")? $msg : $response->getParameter("error", ""); + $response->send(); - $rest = new \Maveriks\Extension\Restler(); - $rest->setMessage(new \Luracast\Restler\RestException(\ProcessMaker\Services\Api::STAT_APP_EXCEPTION, $msg)); - - exit(0); - } else { - $response->send(); - } + exit(0); } } diff --git a/workflow/engine/templates/enterprise/addonsStore.js b/workflow/engine/templates/enterprise/addonsStore.js index 5a265e9df..898899bb1 100644 --- a/workflow/engine/templates/enterprise/addonsStore.js +++ b/workflow/engine/templates/enterprise/addonsStore.js @@ -1443,54 +1443,6 @@ Ext.onReady(function() { } return ''; } - }, - { - id : "status-feature", - header : _('ID_STATUS'), - width : 60, - sortable : false, - hideable : false, - dataIndex: "status", - renderer: function (val) { - var str = ""; - var text = ""; - - switch (val) { - case "available": text = _('ID_BUY_NOW'); break; - case "installed": text = _('ID_INSTALLED'); break; - case "ready": text = _('ID_INSTALL_NOW'); break; - case "upgrade": text = _('ID_UPGRADE_NOW'); break; - case "download": text = _('ID_CANCEL'); break; - case "install": text = _('ID_INSTALLING'); break; - case "cancel": text = _('ID_CANCELLING'); break; - case "disabled": text = _('ID_DISABLED'); break; - case "download-start": text = ""; break; - default: text = val; break; - } - - switch (val) { - case "available": - case "ready": - case "upgrade": - case "download": - case "install": - case "cancel": - case "download-start": - str = "
    " + text + "
    "; - break; - - case "installed": - case "disabled": - str = "
    " + text + "
    "; - break; - - default: - str = "
    " + text + "
    "; - break; - } - - return (str); - } } ] }); diff --git a/workflow/engine/templates/setup/newSite.js b/workflow/engine/templates/setup/newSite.js index 17682f224..badfc12e5 100755 --- a/workflow/engine/templates/setup/newSite.js +++ b/workflow/engine/templates/setup/newSite.js @@ -198,20 +198,23 @@ Ext.onReady(function(){ function createNW(nwTitle, aoDbWf, aoDbRb, aoDbRp, nwUsername, nwPassword, nwPassword2){ PMExt.confirm(_('ID_CONFIRM'), _('NEW_SITE_CONFIRM_TO_CREATE'), function(){ var loadMask = new Ext.LoadMask(document.body, {msg : _('ID_SITE_CREATING')}); + var oParams = { + action : 'create', + NW_TITLE : nwTitle, + AO_DB_WF : aoDbWf, + AO_DB_RB : aoDbRb, + AO_DB_RP : aoDbRp, + NW_USERNAME : nwUsername, + NW_PASSWORD : nwPassword, + NW_PASSWORD2 : nwPassword2 + }; + if(aoDbDrop){ + oParams.AO_DB_DROP = 'On'; + } loadMask.show(); Ext.Ajax.request({ url: '../newSiteProxy/testingNW', - params: { - action : 'create', - NW_TITLE : nwTitle, - AO_DB_WF : aoDbWf, - AO_DB_RB : aoDbRb, - AO_DB_RP : aoDbRp, - NW_USERNAME : nwUsername, - NW_PASSWORD : nwPassword, - NW_PASSWORD2 : nwPassword2, - AO_DB_DROP : aoDbDrop - }, + params: oParams, method: 'POST', success: function ( result, request ) { loadMask.hide(); diff --git a/workflow/engine/templates/strategicDashboard/formDashboard.js b/workflow/engine/templates/strategicDashboard/formDashboard.js index 950714d06..ab4025611 100644 --- a/workflow/engine/templates/strategicDashboard/formDashboard.js +++ b/workflow/engine/templates/strategicDashboard/formDashboard.js @@ -504,7 +504,7 @@ Ext.onReady( function() { enableTabScroll : true, //anchor : '98%', width : '100%', - height : 315, + height : 260, defaults : { autoScroll :true }, @@ -574,7 +574,13 @@ Ext.onReady( function() { if (typeof dataIndicator[id-1]['DAS_IND_DIRECTION'] != 'undefined') { Ext.getCmp('DAS_IND_DIRECTION_'+id).setValue(idDirection); } - if (dataIndicator[id-1]['DAS_IND_TYPE'] != '1010' && dataIndicator[id-1]['DAS_IND_TYPE'] != '1030') { + var field = ''; + if (dataIndicator[id-1]['DAS_IND_TYPE'] != '1050') { + field = Ext.getCmp('IND_PROCESS_'+id); + field.enable(); + field.show(); + } + if (dataIndicator[id-1]['DAS_IND_TYPE'] != '1010' && dataIndicator[id-1]['DAS_IND_TYPE'] != '1030' && dataIndicator[id-1]['DAS_IND_TYPE'] != '1050') { var fields = ['DAS_IND_FIRST_FIGURE_'+id,'DAS_IND_FIRST_FREQUENCY_'+ id,'DAS_IND_SECOND_FIGURE_'+id, 'DAS_IND_SECOND_FREQUENCY_'+ id]; for (var k=0; k