From e637bed741d8b80dec5f91816c15f9b36625c742 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Mena Date: Wed, 1 Apr 2015 10:01:38 -0400 Subject: [PATCH 01/12] Improvement form Dashboards - validation show tab --- .../strategicDashboard/formDashboard.js | 93 +++++++++++-------- .../strategicDashboard/viewDashboard.html | 4 +- 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/workflow/engine/templates/strategicDashboard/formDashboard.js b/workflow/engine/templates/strategicDashboard/formDashboard.js index 9e9ffb4ba..96e91b426 100644 --- a/workflow/engine/templates/strategicDashboard/formDashboard.js +++ b/workflow/engine/templates/strategicDashboard/formDashboard.js @@ -474,7 +474,8 @@ Ext.onReady( function() { OWNER_LABEL : selection.data.field1, OWNER_TYPE : selection.data.field3 }); - store.insert(store.getCount(), ow); + ownerInfoGrid.store.insert(store.getCount(), ow); + ownerInfoGrid.store.totalCount = data.length +1; ownerInfoGrid.getView().refresh(); Ext.getCmp('searchIem').clearValue(); @@ -663,7 +664,7 @@ Ext.onReady( function() { text : _('ID_CANCEL'), id : 'cancel', handler : function(){ - location.href = 'dashboardList'; + window.location = 'dashboardList'; } } ] @@ -710,7 +711,6 @@ Ext.onReady( function() { loadIndicators(DAS_UID); } else { addTab(); - tabPanel.getItem(0).show(); } if (typeof(__DASHBOARD_ERROR__) !== 'undefined') { @@ -719,12 +719,13 @@ Ext.onReady( function() { }); //==============================================================// -var addTab = function () { +var addTab = function (flag) { + console.log('flag', flag); if (tabPanel.items.items.length > 3 ) { PMExt.warning(_('ID_DASHBOARD'), _('ID_MAX_INDICATOR_DASHBOARD')); return false; } - tabPanel.add({ + var tab = { //title : _('ID_INDICATOR') + (++indexTab), title : _('ID_INDICATOR')+ ' '+ (++indexTab), id : indexTab, @@ -789,38 +790,43 @@ var addTab = function () { } } }), - { - fieldLabel : _('ID_INDICATOR_GOAL'), - id : 'IND_GOAL_'+ indexTab, - xtype : 'textfield', - anchor : '40%', - maskRe : /([0-9\.]+)$/, - maxLength : 9, - width : 8, - allowBlank : false - }, - new Ext.form.ComboBox({ - anchor : '85%', - editable : false, - fieldLabel : _('ID_DIRECTION'), - id : 'DAS_IND_DIRECTION_'+ indexTab, - displayField : 'label', - valueField : 'id', - value : 2, - forceSelection : false, - selectOnFocus : true, - typeAhead : true, - autocomplete : true, - triggerAction : 'all', - mode : 'local', - store : new Ext.data.ArrayStore({ - id: 0, - fields: [ - 'id', - 'label' - ], - data: [['1', _('ID_LESS_THAN')], ['2', _('ID_MORE_THAN')]] - }) + new Ext.form.FieldSet({ + title : _('ID_INDICATOR_GOAL'), + bodyStyle: 'paddingLeft: 143px', + layout : 'hbox', + items : [ + new Ext.form.ComboBox({ + editable : false, + id : 'DAS_IND_DIRECTION_'+ indexTab, + displayField : 'label', + valueField : 'id', + value : 2, + forceSelection : false, + selectOnFocus : true, + typeAhead : true, + autocomplete : true, + triggerAction : 'all', + mode : 'local', + store : new Ext.data.ArrayStore({ + id: 0, + fields: [ + 'id', + 'label' + ], + data: [['1', _('ID_LESS_THAN')], ['2', _('ID_MORE_THAN')]] + }) + }), + { + fieldLabel : _('ID_INDICATOR_GOAL'), + id : 'IND_GOAL_'+ indexTab, + xtype : 'textfield', + anchor : '40%', + maskRe : /([0-9\.]+)$/, + maxLength : 9, + width : 80, + allowBlank : false + } + ] }), new Ext.form.ComboBox({ anchor : '85%', @@ -915,7 +921,12 @@ var addTab = function () { }, }, closable:true - })/*.show(false)*/; + }; + if (flag != 'load') { + tabPanel.add(tab).show(); + } else { + tabPanel.add(tab); + } }; @@ -1116,7 +1127,7 @@ var saveAllIndicators = function (DAS_UID) { } saveDashboardIndicator(data); } - location.href = 'dashboardList'; + window.location = 'dashboardList'; }; @@ -1233,12 +1244,12 @@ var loadIndicators = function (DAS_UID) { success: function (response) { var jsonResp = Ext.util.JSON.decode(response.responseText); if (jsonResp == '') { - addTab(); + addTab('load'); } dataIndicator = jsonResp; for (var i=0; i<=jsonResp.length-1; i++) { - addTab(); + addTab('load'); tabPanel.getItem(i+1).setTitle(jsonResp[i]['DAS_IND_TITLE']); } tabPanel.getItem(0).show(); diff --git a/workflow/engine/templates/strategicDashboard/viewDashboard.html b/workflow/engine/templates/strategicDashboard/viewDashboard.html index 0b26072fc..0add7273a 100644 --- a/workflow/engine/templates/strategicDashboard/viewDashboard.html +++ b/workflow/engine/templates/strategicDashboard/viewDashboard.html @@ -29,13 +29,13 @@ - From 3851363a9d14bf59fb3a8a751ae19bec8289f822 Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 1 Apr 2015 11:24:19 -0400 Subject: [PATCH 02/12] Indicaros Calculator with PDO --- .../classes/class.indicatorsCalculator.php | 512 +++++++----------- 1 file changed, 197 insertions(+), 315 deletions(-) diff --git a/workflow/engine/classes/class.indicatorsCalculator.php b/workflow/engine/classes/class.indicatorsCalculator.php index 2f4674f3d..938433bad 100644 --- a/workflow/engine/classes/class.indicatorsCalculator.php +++ b/workflow/engine/classes/class.indicatorsCalculator.php @@ -70,8 +70,6 @@ abstract class IndicatorDataSourcesEnum extends BasicEnum { class indicatorsCalculator { - private static $connectionName = 'workflow'; - private $userReportingMetadata = array("tableName" => "USR_REPORTING", "keyField" => "USR_UID"); private $processReportingMetadata = array("tableName" => "PRO_REPORTING", "keyField" => "PRO_UID"); private $userGroupReportingMetadata = array("tableName" => "USR_REPORTING", "keyField" => "USR_UID"); @@ -83,30 +81,58 @@ class indicatorsCalculator private $ueiCostFormula = "SUM(TOTAL_CASES_OUT * CONFIGURED_TASK_TIME - TOTAL_TIME_BY_TASK * USER_HOUR_COST)"; private $ueiFormula = "SUM(TOTAL_CASES_OUT * CONFIGURED_TASK_TIME) / SUM(TOTAL_TIME_BY_TASK * USER_HOUR_COST)"; -// -// public function processEfficiencyIndex($processList, $initDate, $endDate) -// { -// $resultList = $this->processEfficiencyIndexList($processList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return ($resultList[0]['PEI']); -// } + public function getSkewOfDataDistribution($table, $field) { + /*$sqlString = "SET @median = (SELECT x.$field from $table x, $table y + GROUP BY x.$field + HAVING SUM(SIGN(1-SIGN(y.$field-x.$field)))/COUNT(*) > .5 + LIMIT 1)"; + */ + + $sqlString = "SELECT x.$field from $table x, $table y + GROUP BY x.$field + HAVING SUM(SIGN(1-SIGN(y.$field-x.$field)))/COUNT(*) > .5 + LIMIT 1"; + + $returnValue = 0; + $connection = $this->pdoConnection(); + $result = $this->pdoExecutorWithConnection($sqlString, array(), $connection); + $result2 = $this->pdoExecutorWithConnection("select @median", array(), $connection); + print_r($result2); + if (sizeof($result) > 0) { + $returnValue = current(reset($result2)); + } + return $returnValue; + } public function peiHistoric($processId, $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); - $sqlString = $this->indicatorsBasicQueryBuilder(IndicatorDataSourcesEnum::USER + /*$sqlString = $this->indicatorsBasicQueryBuilder(IndicatorDataSourcesEnum::USER , $processId, $periodicity, $initDate, $endDate - , $this->peiFormula); + , $this->peiFormula);*/ - $returnValue = $this->propelExecutor($sqlString); + $qryParams = Array(); + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::USER + , $processId, $periodicity, $initDate, $endDate + , $this->peiFormula, $qryParams); + + //$returnValue = $this->propelExecutor($sqlString); + + $returnValue = $this->pdoExecutor($sqlString, $qryParams); return $returnValue; } public function indicatorData($indicatorId) { - $sqlString = "select * from DASHBOARD_INDICATOR where DAS_IND_UID= '$indicatorId'"; - $retval = $this->propelExecutor($sqlString); - return $retval; + $qryParams = Array(); + $qryParams[':indicatorId'] = $indicatorId; + $sqlString = "select * from DASHBOARD_INDICATOR where DAS_IND_UID= :indicatorId"; + $returnValue = $this->pdoExecutor($sqlString, $qryParams); + + /*$sqlString = "select * from DASHBOARD_INDICATOR where DAS_IND_UID= '$indicatorId'"; + $retval = $this->propelExecutor($sqlString);*/ + return $returnValue; } public function peiProcesses($indicatorId, $initDate, $endDate, $language) @@ -120,6 +146,12 @@ class indicatorsCalculator $endYear = $endDate->format("Y"); $endMonth = $endDate->format("m"); + //$params[":initYear"] = $initYear; + //$params[":initMonth"] = $initMonth; + $params[":endYear"] = $endYear; + $params[":endMonth"] = $endMonth; + $params[":language"] = $language; + $sqlString = " select i.PRO_UID as uid, @@ -139,17 +171,17 @@ class indicatorsCalculator (select DAS_UID_PROCESS from DASHBOARD_INDICATOR where DAS_IND_UID = '$indicatorId')= '0' ) AND - IF (`YEAR` = $initYear, `MONTH`, `YEAR`) >= IF (`YEAR` = $initYear, $initMonth, $initYear) - AND - IF(`YEAR` = $endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = $endYear, $endMonth, $endYear) + IF(`YEAR` = :endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = :endYear, :endMonth, :endYear) group by PRO_UID ) i left join (select * from CONTENT where CON_CATEGORY = 'PRO_TITLE' - and CON_LANG = '$language' + and CON_LANG = :language ) tp on i.PRO_UID = tp.CON_ID"; - $retval = $this->propelExecutor($sqlString); + + //$retval = $this->propelExecutor($sqlString); + $retval = $this->pdoExecutor($sqlString, $params); return $retval; } @@ -165,6 +197,12 @@ class indicatorsCalculator $endYear = $endDate->format("Y"); $endMonth = $endDate->format("m"); + //$params[":initYear"] = $initYear; + //$params[":initMonth"] = $initMonth; + $params[":endYear"] = $endYear; + $params[":endMonth"] = $endMonth; + $params[":language"] = $language; + //TODO ADD to USR_REPORTING the user's Group to speed up the query. $sqlString = " select @@ -185,18 +223,17 @@ class indicatorsCalculator left join GROUP_USER gu on gu.USR_UID = ur.USR_UID WHERE - IF (`YEAR` = $initYear, `MONTH`, `YEAR`) >= IF (`YEAR` = $initYear, $initMonth, $initYear) - AND - IF(`YEAR` = $endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = $endYear, $endMonth, $endYear) + IF(`YEAR` = :endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = :endYear, :endMonth, :endYear) group by gu.GRP_UID ) i left join (select * from CONTENT where CON_CATEGORY = 'GRP_TITLE' - and CON_LANG = 'en' + and CON_LANG = :language ) tp on i.GRP_UID = tp.CON_ID"; - $retval = $this->propelExecutor($sqlString); + $retval = $this->pdoExecutor($sqlString, $params); + //$retval = $this->propelExecutor($sqlString); return $retval; } @@ -213,6 +250,13 @@ class indicatorsCalculator $endYear = $endDate->format("Y"); $endMonth = $endDate->format("m"); + //$params[":initYear"] = $initYear; + //$params[":initMonth"] = $initMonth; + $params[":endYear"] = $endYear; + $params[":endMonth"] = $endMonth; + $params[":language"] = $language; + $params[":groupId"] = $groupId; + $sqlString = " select i.USR_UID as uid, i.name, @@ -232,78 +276,32 @@ class indicatorsCalculator left join GROUP_USER gu on gu.USR_UID = ur.USR_UID LEFT JOIN USERS u on u.USR_UID = ur.USR_UID - where (gu.GRP_UID = '$groupId' or ('$groupId' = '0' && gu.GRP_UID is null )) + where (gu.GRP_UID = :groupId or (:groupId = '0' && gu.GRP_UID is null )) AND - IF (`YEAR` = $initYear, `MONTH`, `YEAR`) >= IF (`YEAR` = $initYear, $initMonth, $initYear) - AND - IF(`YEAR` = $endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = $endYear, $endMonth, $endYear) + IF(`YEAR` = :endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = :endYear, :endMonth, :endYear) group by ur.USR_UID ) i"; - $returnValue = $this->propelExecutor($sqlString); - return $returnValue; + + $retval = $this->pdoExecutor($sqlString, $params); + //$returnValue = $this->propelExecutor($sqlString); + return $retval; } -// -// public function employeeEfficiencyIndex($employeeList, $initDate, $endDate) -// { -// $resultList = $this->employeeEfficiencyIndexList($employeeList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($resultList)); -// } public function ueiHistoric($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); - $sqlString = $this->indicatorsBasicQueryBuilder(IndicatorDataSourcesEnum::USER + $qryParams = Array(); + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::USER , $employeeId, $periodicity, $initDate, $endDate - , $this->ueiFormula); - $returnValue = $this->propelExecutor($sqlString); - return $returnValue; + , $this->ueiFormula, $qryParams); + + $retval = $this->pdoExecutor($sqlString, $qryParams); + //$returnValue = $this->propelExecutor($sqlString); + return $retval; } -// public function employeeEfficiencyCost($employeeList, $initDate, $endDate) -// { -// $resultList = $this->employeeEfficiencyCostList($employeeList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($resultList)); -// } -// -// public function userCostByGroupHistoric($groupId, $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"); -// -// $filterCondition = ""; -// if ($groupId != null && $groupId > 0) { -// $filterCondition = " AND GRP_UID = '$groupId'"; -// } -// -// $sqlString = "SELECT (SUM(CONFIGURED_TASK_TIME) - SUM(TOTAL_TIME_BY_TASK)) * USER_HOUR_COST as EEC -// FROM USR_REPORTING ur -// LEFT JOIN GROUP_USER gu on gu.USR_UID =ur.USR_UID -// LEFT JOIN GROUP_USER gu on gu.USR_UID =ur.USR_UID -// WHERE -// IF (`YEAR` = $initYear, `MONTH`, `YEAR`) >= IF (`YEAR` = $initYear, $initMonth, $initYear) -// AND -// IF(`YEAR` = $endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = $endYear, $endMonth, $endYear)" -// . $filterCondition -// . $periodicityGroup; -// $returnValue = $this->propelExecutor($sqlString); -// return $returnValue; -// } - -// public function processEfficiencyCost($processList, $initDate, $endDate) -// { -// $resultList = $this->processEfficiencyCostList($processList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($resultList)); -// } - public function peiCostHistoric($processId, $initDate, $endDate, $periodicity) { if (!is_a($initDate, 'DateTime')) throw new InvalidArgumentException ('initDate parameter must be a DateTime object.', 0); @@ -317,21 +315,26 @@ class indicatorsCalculator $endYear = $endDate->format("Y"); $endMonth = $endDate->format("m"); + //$params[":initYear"] = $initYear; + //$params[":initMonth"] = $initMonth; + $params[":endYear"] = $endYear; + $params[":endMonth"] = $endMonth; + $params[":processId"] = $processId; + $filterCondition = ""; if ($processId != null && $processId > 0) { - $filterCondition = " AND PRO_UID = '$processId'"; + $filterCondition = " AND PRO_UID = :processId"; } $sqlString = "SELECT $periodicitySelectFields " . $this->peiCostFormula . " as PEC FROM USR_REPORTING WHERE - IF (`YEAR` = $initYear, `MONTH`, `YEAR`) >= IF (`YEAR` = $initYear, $initMonth, $initYear) - AND - IF(`YEAR` = $endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = $endYear, $endMonth, $endYear)" - . $filterCondition - . $periodicityGroup; + IF(`YEAR` = :endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = :endYear, :endMonth, :endYear)" + . $filterCondition + . $periodicityGroup; - $retval = $this->propelExecutor($sqlString); + $retval = $this->pdoExecutor($sqlString, $params); + //$retval = $this->propelExecutor($sqlString); return $retval; } @@ -350,14 +353,6 @@ class indicatorsCalculator if ($indicatorProcessId == "0" || strlen($indicatorProcessId) ==0) { $indicatorProcessId = null; } - //$indicatorJson = unserialize($indicator['DAS_IND_PROPERTIES']); - //$indicatorConfig = json_decode($indicatorJson); - - /*$graph1 = $indicatorConfig->{'IND_FIRST_FIGURE'}; - $freq1 = $indicatorConfig->{'IND_FIRST_FREQUENCY'}; - $graph2 = $indicatorConfig->{'IND_SECOND_FIGURE'}; - $freq2 = $indicatorConfig->{'IND_SECOND_FREQUENCY'}; - */ $graph1 = $indicator['DAS_IND_FIRST_FIGURE']; $freq1 = $indicator['DAS_IND_FIRST_FREQUENCY']; @@ -396,180 +391,16 @@ class indicatorsCalculator throw new Exception(" The indicator id '$indicatorId' with type $indicatorType hasn't an associated operation."); } - $sqlString = $this->indicatorsBasicQueryBuilder(IndicatorDataSourcesEnum::PROCESS + $params = Array(); + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::PROCESS , $indicatorProcessId, $periodicity , $initDate, $endDate - , $calcField); - $returnValue = $this->propelExecutor($sqlString); - return $returnValue; - } -// /***** Indicators for overdue, new, completed ******/ -// public function totalOverdueCasesByProcess($processList, $initDate, $endDate) -// { -// $returnList = $this->totalOverdueCasesByProcessList($processList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($returnList)); -// } -// -// public function totalOverdueCasesByProcessList($processList, $initDate, $endDate, $periodicity) -// { -// return $this->sumCasesListByProcess($processList, $initDate, $endDate, $periodicity, "SUM(TOTAL_CASES_OVERDUE)", ""); -// } -// -// public function totalOverdueCasesByUser($userList, $initDate, $endDate) -// { -// $returnList = $this->totalOverdueCasesByUserList($userList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($returnList)); -// } -// -// public function totalOverdueCasesByUserList($userList, $initDate, $endDate, $periodicity) -// { -// return $this->sumCasesListByUser($userList, $initDate, $endDate, $periodicity, "SUM(TOTAL_CASES_OVERDUE)", ""); -// } -// -// //percent -// public function percentOverdueCasesByProcess($processList, $initDate, $endDate) -// { -// $returnList = $this->percentOverdueCasesByProcessList($processList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($returnList)); -// } -// + , $calcField, $params); -// public function percentOverdueCasesByProcessList($processList, $initDate, $endDate, $periodicity) -// { -// return $this->sumCasesListByProcess($processList, $initDate, $endDate, $periodicity, "100 * SUM(TOTAL_CASES_OVERDUE)", "SUM(TOTAL_CASES_ON_TIME + TOTAL_CASES_OVERDUE)"); -// } -// -// public function percentOverdueCasesByUser($userList, $initDate, $endDate) -// { -// $returnList = $this->percentOverdueCasesByUserList($userList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($returnList)); -// } -// -// public function percentOverdueCasesByUserList($userList, $initDate, $endDate, $periodicity) -// { -// return $this->sumCasesListByUser($userList, $initDate, $endDate, $periodicity, "100 * SUM(TOTAL_CASES_OVERDUE)", "SUM(TOTAL_CASES_ON_TIME + TOTAL_CASES_OVERDUE)"); -// } -// -// //new cases -// public function totalNewCasesByProcess($processList, $initDate, $endDate) -// { -// $returnList = $this->totalNewCasesByProcessList($processList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($returnList)); -// } -// -// public function totalNewCasesByProcessList($processList, $initDate, $endDate, $periodicity) -// { -// return $this->sumCasesListByProcess($processList, $initDate, $endDate, $periodicity, "SUM(TOTAL_CASES_IN)", ""); -// } -// -// public function totalNewCasesByUser($userList, $initDate, $endDate) -// { -// $returnList = $this->totalNewCasesByUserList($userList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($returnList)); -// } -// -// public function totalNewCasesByUserList($userList, $initDate, $endDate, $periodicity) -// { -// return $this->sumCasesListByUser($userList, $initDate, $endDate, $periodicity, "SUM(TOTAL_CASES_IN)", ""); -// } -// -// -// //completed cases -// public function totalCompletedCasesByProcess($processList, $initDate, $endDate) -// { -// $returnList = $this->totalCompletedCasesByProcessList($processList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($returnList)); -// } -// -// public function totalCompletedCasesByProcessList($processList, $initDate, $endDate, $periodicity) -// { -// return $this->sumCasesListByProcess($processList, $initDate, $endDate, $periodicity, "SUM(TOTAL_CASES_OUT)", ""); -// } -// -// public function totalCompletedCasesByUser($userList, $initDate, $endDate) -// { -// $returnList = $this->totalCompletedCasesByUserList($userList, $initDate, $endDate, ReportingPeriodicityEnum::NONE); -// return current(reset($returnList)); -// } -// -// public function totalCompletedCasesByUserList($userList, $initDate, $endDate, $periodicity) -// { -// return $this->sumCasesListByUser($userList, $initDate, $endDate, $periodicity, "SUM(TOTAL_CASES_OUT)", ""); -// } -// -// public function sumCasesListByProcess($processList, $initDate, $endDate, $periodicity, $fieldToProcess, $fieldToCompare) -// { -// if ($processList != null && !is_array($processList)) throw new InvalidArgumentException ('employeeList parameter must be an Array or null value.', 0); -// 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"); -// -// -// $userCondition = ""; -// if ($processList != null && sizeof($processList) > 0) { -// $userCondition = " AND PRO_UID IN " . "('" . implode("','", $processList) . "')"; -// } -// $comparationOperation = ""; -// if (strlen($fieldToCompare) > 0) { -// $comparationOperation = "/$fieldToCompare"; -// } -// -// $sqlString = "SELECT $periodicitySelectFields $fieldToProcess$comparationOperation as Indicator -// FROM PRO_REPORTING -// WHERE -// IF (`YEAR` = $initYear, `MONTH`, `YEAR`) >= IF (`YEAR` = $initYear, $initMonth, $initYear) -// AND -// IF(`YEAR` = $endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = $endYear, $endMonth, $endYear)" -// . $userCondition -// . $periodicityGroup; -// -// $retval = $this->propelExecutor($sqlString); -// return $retval; -// } -// -// public function sumCasesListByUser($processList, $initDate, $endDate, $periodicity, $fieldToProcess, $fieldToCompare) -// { -// if ($processList != null && !is_array($processList)) throw new InvalidArgumentException ('employeeList parameter must be an Array or null value.', 0); -// 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"); -// -// $userCondition = ""; -// if ($processList != null && sizeof($processList) > 0) { -// $userCondition = " AND USR_UID IN " . "('" . implode("','", $processList) . "')"; -// } -// -// $comparationOperation = ""; -// if (strlen($fieldToCompare) > 0) { -// $comparationOperation = "/" . $fieldToCompare; -// } -// -// $sqlString = "SELECT $periodicitySelectFields $fieldToProcess$comparationOperation as Indicator -// FROM USR_REPORTING -// WHERE -// IF (`YEAR` = $initYear, `MONTH`, `YEAR`) >= IF (`YEAR` = $initYear, $initMonth, $initYear) -// AND -// IF(`YEAR` = $endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = $endYear, $endMonth, $endYear)" -// . $userCondition -// . $periodicityGroup; -// -// $retval = $this->propelExecutor($sqlString); -// return $retval; -// } + $retval = $this->pdoExecutor($sqlString, $params); + //$returnValue = $this->propelExecutor($sqlString); + return $retval; + } public function peiTasks($processList, $initDate, $endDate, $language) { @@ -577,7 +408,8 @@ class indicatorsCalculator if ($processList != null && sizeof($processList) > 0) { $processCondition = " WHERE PRO_UID IN " . "('" . implode("','", $processList) . "')"; } - //TODO add dates condition in query + $params[':language'] = $language; + $sqlString = " select i.TAS_UID as uid, t.CON_VALUE as name, @@ -599,53 +431,13 @@ class indicatorsCalculator left join (select * from CONTENT where CON_CATEGORY = 'TAS_TITLE' - and CON_LANG = '$language' + and CON_LANG = :language ) t on i.TAS_UID = t.CON_ID"; - $retval = $this->propelExecutor($sqlString); + $retval = $this->pdoExecutor($sqlString, $params); + //$retval = $this->propelExecutor($sqlString); return $retval; } -// public function employeeTasksInfoList($userList, $initDate, $endDate, $language) -// { -// $userCondition = ""; -// if ($userList != null && sizeof($userList) > 0) { -// $userCondition = " WHERE USR_UID IN " . "('" . implode("','", $userList) . "')"; -// } -// //TODO add dates contidion to query -// $sqlString = " select -// i.PRO_UID as ProcessId, -// tp.CON_VALUE as ProcessTitle, -// i.TAS_UID as TaskId, -// tt.CON_VALUE as TaskTitle, -// i.EfficienceIndex, -// i.TimeAverage, -// i.TimeSdv, -// i.CONFIGURED_TASK_TIME as ConfiguredTime -// FROM -// ( select -// PRO_UID, -// TAS_UID, -// (AVG(CONFIGURED_TASK_TIME) + AVG(SDV_TIME))/ AVG(AVG_TIME) as EfficienceIndex, -// AVG(AVG_TIME) as TimeAverage, -// AVG(SDV_TIME) as TimeSdv, -// CONFIGURED_TASK_TIME -// from USR_REPORTING -// $userCondition -// group by PRO_UID, TAS_UID -// ) i -// left join (select * -// from CONTENT -// where CON_CATEGORY = 'TAS_TITLE' -// and CON_LANG = '$language' -// ) tt on i.TAS_UID = tt.CON_ID -// left join (select * -// from CONTENT -// where CON_CATEGORY = 'PRO_TITLE' -// and CON_LANG = '$language' -// ) tp on i.PRO_UID = tp.CON_ID"; -// $retval = $this->propelExecutor($sqlString); -// return $retval; -// } private function periodicityFieldsForSelect($periodicity) { $periodicityFields = $this->periodicityFieldsString($periodicity); @@ -685,7 +477,7 @@ class indicatorsCalculator return $retval; } - private function propelExecutor($sqlString) { + /*private function propelExecutor($sqlString) { $con = Propel::getConnection(self::$connectionName); $qry = $con->PrepareStatement($sqlString); try { @@ -700,8 +492,49 @@ class indicatorsCalculator } return $rows; } +*/ + private function pdoExecutor($sqlString, $params) { + /*G::loadClass('wsTools'); + $currentWS = defined('SYS_SYS') ? SYS_SYS : 'Wokspace Undefined'; + $workSpace = new workspaceTools($currentWS); + $host = $workSpace->dbHost; + $db = $workSpace->dbName; + $user = $workSpace->dbUser; + $pass = $workSpace->dbPass; - private function indicatorsBasicQueryBuilder($reportingTable, $filterId, $periodicity, $initDate, $endDate, $fields ) { + + $dbh = new PDO("mysql:host=".$host.";dbname=$db;charset=utf8", $user, $pass); + + $statement = $dbh->prepare($sqlString); + + $statement->execute($params); + $result = $statement->fetchAll(PDO::FETCH_ASSOC); */ + + $connection = $this->pdoConnection (); + $result = $this->pdoExecutorWithConnection($sqlString, $params, $connection); + return $result; + } + + private function pdoConnection() { + G::loadClass('wsTools'); + $currentWS = defined('SYS_SYS') ? SYS_SYS : 'Wokspace Undefined'; + $workSpace = new workspaceTools($currentWS); + $host = $workSpace->dbHost; + $db = $workSpace->dbName; + $user = $workSpace->dbUser; + $pass = $workSpace->dbPass; + $dbh = new PDO("mysql:host=".$host.";dbname=$db;charset=utf8", $user, $pass); + return $dbh; + } + + private function pdoExecutorWithConnection($sqlString, $params, $connection) { + $statement = $connection->prepare($sqlString); + $statement->execute($params); + $result = $statement->fetchAll(PDO::FETCH_ASSOC); + return $result; + } + + /*private function indicatorsBasicQueryBuilder($reportingTable, $filterId, $periodicity, $initDate, $endDate, $fields ) { 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); @@ -727,8 +560,41 @@ class indicatorsCalculator . $filterCondition . $periodicityGroup; return $sqlString; + }*/ + + + private function indicatorsParamsQueryBuilder($reportingTable, $filterId, $periodicity, $initDate, $endDate, $fields, &$params) { + 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); + + $tableMetadata = $this->metadataForTable($reportingTable); + $periodicitySelectFields = $this->periodicityFieldsForSelect($periodicity); + $periodicityGroup = $this->periodicityFieldsForGrouping($periodicity); + $initYear = $initDate->format("Y"); + $initMonth = $initDate->format("m"); + $endYear = $endDate->format("Y"); + $endMonth = $endDate->format("m"); + + $filterCondition = ""; + if ($filterId != null && $filterId > 0) { + $filterCondition = " AND ".$tableMetadata["keyField"]." = '$filterId'"; + } + + //$params[":initYear"] = $initYear; + //$params[":initMonth"] = $initMonth; + $params[":endYear"] = $endYear; + $params[":endMonth"] = $endMonth; + + $sqlString = "SELECT $periodicitySelectFields $fields + FROM ".$tableMetadata["tableName"]. + " WHERE + IF(`YEAR` = :endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = :endYear, :endMonth, :endYear)" + . $filterCondition + . $periodicityGroup; + return $sqlString; } + private function metadataForTable($table) { $returnVal = null; switch (strtolower($table)) { @@ -750,6 +616,22 @@ class indicatorsCalculator } return $returnVal; } + + + public function interpolateQuery($query, $params) { + $keys = array(); + # build a regular expression for each parameter + foreach ($params as $key => $value) { + echo "
llave", $key, " -- valor", $value; + if (is_string($key)) { + $keys[] = '/:'.$key.'/'; + } else { + $keys[] = '/[?]/'; + } + } + $query = preg_replace($keys, $params, $query, 1, $count); + return $query; + } } From 0329f7709a4e4264d8465a71ccb6fd6fa141e086 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Mena Date: Wed, 1 Apr 2015 20:39:12 -0400 Subject: [PATCH 03/12] Improvement save form Dashboards --- .../engine/classes/model/AppCacheView.php | 107 ++++++++--------- workflow/engine/data/mysql/insert.sql | 1 - workflow/engine/menus/processmaker.php | 2 +- .../triggerFillReportByProcess.sql | 1 - .../strategicDashboard/formDashboard.js | 111 +++++++++--------- 5 files changed, 105 insertions(+), 117 deletions(-) diff --git a/workflow/engine/classes/model/AppCacheView.php b/workflow/engine/classes/model/AppCacheView.php index 8e8624b11..9a2d1a8de 100755 --- a/workflow/engine/classes/model/AppCacheView.php +++ b/workflow/engine/classes/model/AppCacheView.php @@ -1793,67 +1793,52 @@ class AppCacheView extends BaseAppCacheView return $criteria; } - /*----------------------------------********---------------------------------*/ - function fillReportByUser () - { - try { - global $sFilter; - global $dateInit; - global $dateFinish; - - if (strpos($sFilter, 'report_by_user') === false) { - return false; - } - if ($dateInit == null) { - eprintln("You must enter the starting date.", "red"); - eprintln('Example: +init-date"YYYY-MM-DD HH:MM:SS" +finish-date"YYYY-MM-DD HH:MM:SS"', "red"); - return false; - } - - $dateFinish = ($dateFinish != null) ? $dateFinish : date("Y-m-d H:i:s"); - - $appcv = new AppCacheView(); - $appcv->setPathToAppCacheFiles( PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP ); - setExecutionMessage("Calculating data to fill the 'User Reporting'..."); - $appcv->fillReportByUser($dateInit, $dateFinish); - setExecutionResultMessage("DONE"); - } catch (Exception $e) { - setExecutionResultMessage("WITH ERRORS", "error"); - eprintln(" '-" . $e->getMessage(), "red"); - saveLog("fillReportByUser", "error", "Error in fill report by user: " . $e->getMessage()); - } - } - - function fillReportByProcess () - { - try { - global $sFilter; - global $dateInit; - global $dateFinish; - - if (strpos($sFilter, 'report_by_process') === false) { - return false; - } - - if ($dateInit == null) { - eprintln("You must enter the starting date.", "red"); - eprintln('Example: +init-date"YYYY-MM-DD HH:MM:SS" +finish-date"YYYY-MM-DD HH:MM:SS"', "red"); - return false; - } - - $dateFinish = ($dateFinish != null) ? $dateFinish : date("Y-m-d H:i:s"); - $appcv = new AppCacheView(); - $appcv->setPathToAppCacheFiles( PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP ); - - setExecutionMessage("Calculating data to fill the 'Process Reporting'..."); - $appcv->fillReportByProcess($dateInit, $dateFinish); - setExecutionResultMessage("DONE"); - } catch (Exception $e) { - setExecutionResultMessage("WITH ERRORS", "error"); - eprintln(" '-" . $e->getMessage(), "red"); - saveLog("fillReportByProcess", "error", "Error in fill report by process: " . $e->getMessage()); - } - } + /*----------------------------------********---------------------------------*/ + public function fillReportByUser ($dateInit, $dateFinish) + { + $con = Propel::getConnection("workflow"); + $stmt = $con->createStatement(); + + $filenameSql = $this->pathToAppCacheFiles . "triggerFillReportByUser.sql"; + + if (!file_exists($filenameSql)) { + throw (new Exception("file triggerFillReportByUser.sql doesn't exist")); + } + + $sql = "TRUNCATE TABLE USR_REPORTING"; + $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); + + $sql = explode(';', file_get_contents($filenameSql)); + + foreach ($sql as $key => $val) { + $val = str_replace('{init_date}', $dateInit, $val); + $val = str_replace('{finish_date}', $dateFinish, $val); + $stmt->executeQuery($val); + } + } + + public function fillReportByProcess ($dateInit, $dateFinish) + { + $con = Propel::getConnection("workflow"); + $stmt = $con->createStatement(); + + $filenameSql = $this->pathToAppCacheFiles . "triggerFillReportByProcess.sql"; + + if (!file_exists($filenameSql)) { + throw (new Exception("file triggerFillReportByProcess.sql doesn't exist")); + } + + $sql = "TRUNCATE TABLE PRO_REPORTING"; + $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); + + $sql = explode(';', file_get_contents($filenameSql)); + + foreach ($sql as $key => $val) { + $val = str_replace('{init_date}', $dateInit, $val); + $val = str_replace('{finish_date}', $dateFinish, $val); + $stmt->executeQuery($val); + } + } /*----------------------------------********---------------------------------*/ } diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 527ae5862..5ae24fc38 100755 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -59952,7 +59952,6 @@ INSERT INTO CATALOG (CAT_UID, CAT_LABEL_ID, CAT_TYPE, CAT_FLAG, CAT_OBSERVATION, ('300','ID_SEMESTER','PERIODICITY','','','2015-03-04','2015-03-04'), ('400','ID_YEAR','PERIODICITY','','','2015-03-04','2015-03-04'), ('1010','ID_PROCESS_EFFICIENCE','INDICATOR','','','2015-03-04','2015-03-04'), -('1020','ID_PROCESS_INEFFICIENCE','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'), diff --git a/workflow/engine/menus/processmaker.php b/workflow/engine/menus/processmaker.php index 3a72c200d..00938be7a 100755 --- a/workflow/engine/menus/processmaker.php +++ b/workflow/engine/menus/processmaker.php @@ -55,7 +55,7 @@ if ($RBAC->userCanAccess('PM_SETUP') == 1 || $RBAC->userCanAccess('PM_USERS') == // NEW DASHBOARD MODULE $licensedFeatures = & PMLicensedFeatures::getSingleton(); if ($licensedFeatures->verifyfeature('r19Vm5DK1UrT09MenlLYjZxejlhNUZ1b1NhV0JHWjBsZEJ6dnpJa3dTeWVLVT0=') && ($RBAC->userCanAccess('PM_SETUP') == 1 || $RBAC->userCanAccess('PM_USERS') == 1)) { - $G_TMP_MENU->AddIdRawOption('DASHBOARD+', 'strategicDashboard/main', G::LoadTranslation('ID_DASHBOARD'), '', '', '', 'x-pm-dashboard'); + $G_TMP_MENU->AddIdRawOption('DASHBOARD+', 'strategicDashboard/main', G::LoadTranslation('ID_STRATEGIC_DASHBOARD'), '', '', '', 'x-pm-dashboard'); } /*----------------------------------********---------------------------------*/ diff --git a/workflow/engine/methods/setup/setupSchemas/triggerFillReportByProcess.sql b/workflow/engine/methods/setup/setupSchemas/triggerFillReportByProcess.sql index da1aeef85..eb3dc4808 100644 --- a/workflow/engine/methods/setup/setupSchemas/triggerFillReportByProcess.sql +++ b/workflow/engine/methods/setup/setupSchemas/triggerFillReportByProcess.sql @@ -20,7 +20,6 @@ INSERT INTO PRO_REPORTING ( TOTAL_CASES_OVERDUE, TOTAL_CASES_ON_TIME ) - SELECT APPLICATION.PRO_UID, DATE_FORMAT(APPLICATION.APP_INIT_DATE, '%m') AS `MONTH`, diff --git a/workflow/engine/templates/strategicDashboard/formDashboard.js b/workflow/engine/templates/strategicDashboard/formDashboard.js index 96e91b426..036ca32bd 100644 --- a/workflow/engine/templates/strategicDashboard/formDashboard.js +++ b/workflow/engine/templates/strategicDashboard/formDashboard.js @@ -506,7 +506,7 @@ Ext.onReady( function() { enableTabScroll : true, //anchor : '98%', width : '100%', - height : 300, + height : 315, defaults : { autoScroll :true }, @@ -663,7 +663,7 @@ Ext.onReady( function() { { text : _('ID_CANCEL'), id : 'cancel', - handler : function(){ + handler : function() { window.location = 'dashboardList'; } } @@ -726,13 +726,14 @@ var addTab = function (flag) { return false; } var tab = { - //title : _('ID_INDICATOR') + (++indexTab), title : _('ID_INDICATOR')+ ' '+ (++indexTab), id : indexTab, iconCls : 'tabs', + width : "100%", items : [ new Ext.Panel({ - height : 260, + height : 275, + width : "100%", border : true, bodyStyle : 'padding:10px', items : [ @@ -792,7 +793,11 @@ var addTab = function (flag) { }), new Ext.form.FieldSet({ title : _('ID_INDICATOR_GOAL'), - bodyStyle: 'paddingLeft: 143px', + width : "90%", + id : 'fieldSet_'+ indexTab, + bodyStyle: 'paddingLeft: 75px;', + paddingLeft: "30px", + marginLeft : "60px", layout : 'hbox', items : [ new Ext.form.ComboBox({ @@ -826,7 +831,18 @@ var addTab = function (flag) { width : 80, allowBlank : false } - ] + ], + listeners: + { + render: function() + { + var index = tabPanel.getActiveTab().id; + var myfieldset = document.getElementById('fieldSet_'+index); + myfieldset.style.marginLeft = "70px"; + myfieldset.style.marginRight = "70px"; + } + } + }), new Ext.form.ComboBox({ anchor : '85%', @@ -1065,6 +1081,11 @@ var saveAllIndicators = function (DAS_UID) { } tabPanel.getItem(tabActivate[tab]).show(); var fieldsTab = tabPanel.getItem(tabActivate[tab]).items.items[0].items.items[0].items.items; + var goal = fieldsTab[3]; + delete fieldsTab[3]; + fieldsTab.push(goal.items.items[0]); + fieldsTab.push(goal.items.items[1]); + data = []; data['DAS_UID'] = DAS_UID; @@ -1076,54 +1097,38 @@ var saveAllIndicators = function (DAS_UID) { } id = node.id; - value = node.getValue(); - switch (index) { - case "0": - data['DAS_IND_UID'] = value.trim(); - break; - case "1": - if (value.trim() == '') { - PMExt.warning(_('ID_DASHBOARD'), _('ID_INDICATOR_TITLE_REQUIRED', tabPanel.getItem(tabActivate[tab]).title)); - node.focus(true,10); - return false; - } - data['DAS_IND_TITLE'] = value.trim(); - break; - case "2": - if (value.trim() == '') { - PMExt.warning(_('ID_DASHBOARD'), _('ID_INDICATOR_TYPE_REQUIRED', tabPanel.getItem(tabActivate[tab]).title)); - node.focus(true,10); - return false; - } - data['DAS_IND_TYPE'] = value.trim(); - break; - case "3": - data['DAS_IND_GOAL'] = value.trim(); - break; - case "4": - data['DAS_IND_DIRECTION'] = value; - break; - case "5": - if (value.trim() == '') { - PMExt.warning(_('ID_DASHBOARD'), _('ID_INDICATOR_PROCESS_REQUIRED', tabPanel.getItem(tabActivate[tab]).title)); - node.focus(true,10); - return false; - } - data['DAS_UID_PROCESS'] = value; - break; - case "6": - data['DAS_IND_FIRST_FIGURE'] = value; - break; - case "7": - data['DAS_IND_FIRST_FREQUENCY'] = value; - break; - case "8": - data['DAS_IND_SECOND_FIGURE'] = value; - break; - case "9": - data['DAS_IND_SECOND_FREQUENCY'] = value; - break; + id = id.split('_'); + field = ''; + for (var part = 0; part Date: Thu, 2 Apr 2015 11:17:25 -0400 Subject: [PATCH 04/12] PDO connection problem solved --- workflow/engine/classes/class.indicatorsCalculator.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/workflow/engine/classes/class.indicatorsCalculator.php b/workflow/engine/classes/class.indicatorsCalculator.php index 938433bad..1dcf45d98 100644 --- a/workflow/engine/classes/class.indicatorsCalculator.php +++ b/workflow/engine/classes/class.indicatorsCalculator.php @@ -520,10 +520,16 @@ class indicatorsCalculator $currentWS = defined('SYS_SYS') ? SYS_SYS : 'Wokspace Undefined'; $workSpace = new workspaceTools($currentWS); $host = $workSpace->dbHost; - $db = $workSpace->dbName; + + $arrayHost = split(":", $workSpace->dbHost); + $host = "host=".$arrayHost[0]; + $port = sizeof($arrayHost) > 0 ? ";port=".$arrayHost[1] : ""; + $db = ";dbname=".$workSpace->dbName; $user = $workSpace->dbUser; $pass = $workSpace->dbPass; - $dbh = new PDO("mysql:host=".$host.";dbname=$db;charset=utf8", $user, $pass); + $connString = "mysql:$host$port$db;"; + + $dbh = new PDO($connString, $user, $pass); return $dbh; } From e7806cc7c856fa5e4ddf1096c1d6e9da588108b7 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Mena Date: Thu, 2 Apr 2015 13:25:13 -0400 Subject: [PATCH 05/12] Improvement security form dashboards --- .../engine/controllers/strategicDashboard.php | 8 ++++- .../methods/strategicDashboard/main.php | 7 ++++ .../strategicDashboard/formDashboard.js | 34 ++++++++----------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/workflow/engine/controllers/strategicDashboard.php b/workflow/engine/controllers/strategicDashboard.php index 3ca5eaaf9..816785102 100644 --- a/workflow/engine/controllers/strategicDashboard.php +++ b/workflow/engine/controllers/strategicDashboard.php @@ -20,11 +20,17 @@ class StrategicDashboard extends Controller { global $RBAC; - if ($RBAC->userCanAccess('PM_DASHBOARD') != 1) { + if ($RBAC->userCanAccess('PM_SETUP') != 1) { G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::header( 'location: login/login' ); exit(0); } + $licensedFeatures = & PMLicensedFeatures::getSingleton(); + if (!$licensedFeatures->verifyfeature('r19Vm5DK1UrT09MenlLYjZxejlhNUZ1b1NhV0JHWjBsZEJ6dnpJa3dTeWVLVT0=')) { + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die; + } $this->usrId = $RBAC->aUserInfo['USER_INFO']['USR_UID']; $this->urlProxy = '/api/1.0/' . SYS_SYS . '/'; //change diff --git a/workflow/engine/methods/strategicDashboard/main.php b/workflow/engine/methods/strategicDashboard/main.php index a5053057a..03d00600e 100644 --- a/workflow/engine/methods/strategicDashboard/main.php +++ b/workflow/engine/methods/strategicDashboard/main.php @@ -24,6 +24,13 @@ $RBAC->requirePermissions( 'PM_DASHBOARD' ); +$licensedFeatures = & PMLicensedFeatures::getSingleton(); +if (!$licensedFeatures->verifyfeature('r19Vm5DK1UrT09MenlLYjZxejlhNUZ1b1NhV0JHWjBsZEJ6dnpJa3dTeWVLVT0=')) { + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die; +} + $G_MAIN_MENU = 'processmaker'; $G_ID_MENU_SELECTED = 'DASHBOARD+'; diff --git a/workflow/engine/templates/strategicDashboard/formDashboard.js b/workflow/engine/templates/strategicDashboard/formDashboard.js index 036ca32bd..90f2f4170 100644 --- a/workflow/engine/templates/strategicDashboard/formDashboard.js +++ b/workflow/engine/templates/strategicDashboard/formDashboard.js @@ -147,7 +147,8 @@ Ext.onReady( function() { sortInfo: { field: 'OWNER_TYPE', direction: 'ASC' - } + }, + autoLoad: true }); storeGroup = new Ext.data.GroupingStore( { @@ -387,21 +388,13 @@ Ext.onReady( function() { ownerInfoGrid = new Ext.grid.GridPanel({ region : 'center', - //layout : 'fit', id : 'ownerInfoGrid', height : 200, - //autoWidth : true, - //anchor : '80%', width : '100%', - //stateful : true, stateId : 'gridDashboardList', - //enableColumnResize : true, enableHdMenu: true, frame : false, columnLines : false, - /*viewConfig : { - forceFit:true - },*/ store: store, cm: cmodel, sm: smodel, @@ -476,6 +469,7 @@ Ext.onReady( function() { }); ownerInfoGrid.store.insert(store.getCount(), ow); ownerInfoGrid.store.totalCount = data.length +1; + ownerInfoGrid.store.sort('OWNER_LABEL', 'ASC'); ownerInfoGrid.getView().refresh(); Ext.getCmp('searchIem').clearValue(); @@ -720,7 +714,6 @@ Ext.onReady( function() { //==============================================================// var addTab = function (flag) { - console.log('flag', flag); if (tabPanel.items.items.length > 3 ) { PMExt.warning(_('ID_DASHBOARD'), _('ID_MAX_INDICATOR_DASHBOARD')); return false; @@ -805,15 +798,16 @@ var addTab = function (flag) { id : 'DAS_IND_DIRECTION_'+ indexTab, displayField : 'label', valueField : 'id', - value : 2, + value : '2', forceSelection : false, selectOnFocus : true, typeAhead : true, autocomplete : true, triggerAction : 'all', mode : 'local', + allowBlank : false, store : new Ext.data.ArrayStore({ - id: 0, + id: 2, fields: [ 'id', 'label' @@ -1081,12 +1075,11 @@ var saveAllIndicators = function (DAS_UID) { } tabPanel.getItem(tabActivate[tab]).show(); var fieldsTab = tabPanel.getItem(tabActivate[tab]).items.items[0].items.items[0].items.items; + var goal = fieldsTab[3]; - delete fieldsTab[3]; fieldsTab.push(goal.items.items[0]); fieldsTab.push(goal.items.items[1]); - data = []; data['DAS_UID'] = DAS_UID; @@ -1097,6 +1090,9 @@ var saveAllIndicators = function (DAS_UID) { } id = node.id; + if (id.indexOf('fieldSet_') != -1 ) { + continue; + } id = id.split('_'); field = ''; for (var part = 0; part Date: Thu, 2 Apr 2015 16:09:23 -0400 Subject: [PATCH 06/12] Dashboard responsiveness improvementes and solution to NDD-34 --- .../engine/js/strategicDashboard/dashboard.js | 74 ++++++++++++++++--- .../strategicDashboard/viewDashboard.html | 66 ++++++++++------- 2 files changed, 102 insertions(+), 38 deletions(-) diff --git a/workflow/engine/js/strategicDashboard/dashboard.js b/workflow/engine/js/strategicDashboard/dashboard.js index 1825e2df4..1a68c3856 100644 --- a/workflow/engine/js/strategicDashboard/dashboard.js +++ b/workflow/engine/js/strategicDashboard/dashboard.js @@ -255,7 +255,7 @@ //Items by each type: var proEffic = '
\ -
\ +
\
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 = '
\ + var proEfficDetail = '
\ '; - var generalDataLow = '
'; + var generalDataLow = '
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
'; - var generalDataGreat = '
'; + var generalDataGreat = '
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
'; - var oType; var actualDashId; diff --git a/workflow/engine/templates/strategicDashboard/viewDashboard.html b/workflow/engine/templates/strategicDashboard/viewDashboard.html index 0add7273a..72a63c3b4 100644 --- a/workflow/engine/templates/strategicDashboard/viewDashboard.html +++ b/workflow/engine/templates/strategicDashboard/viewDashboard.html @@ -56,37 +56,47 @@

{translate label="ID_MANAGERS_DASHBOARDS"}

-
-
{translate label="ID_DASH_COMPARE_MONTH"}:
- +
- +
+
+
{translate label="ID_DASH_COMPARE_MONTH"}:
+
- +
+ +
+
+ + + +
+ +
From 670ef37001ffa4fe3994a4d83798471dde514c30 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Mena Date: Thu, 2 Apr 2015 18:33:42 -0400 Subject: [PATCH 07/12] Improvement validations IE, FF --- .../strategicDashboard/formDashboard.js | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/workflow/engine/templates/strategicDashboard/formDashboard.js b/workflow/engine/templates/strategicDashboard/formDashboard.js index 90f2f4170..72bda3884 100644 --- a/workflow/engine/templates/strategicDashboard/formDashboard.js +++ b/workflow/engine/templates/strategicDashboard/formDashboard.js @@ -209,7 +209,8 @@ Ext.onReady( function() { store: store, displayInfo: true, displayMsg: _('ID_GRID_PAGE_DISPLAYING_0WNER_MESSAGE') + '    ', - emptyMsg: _('ID_GRID_PAGE_NO_OWNER_MESSAGE'), + //emptyMsg: _('ID_GRID_PAGE_NO_OWNER_MESSAGE') + emptyMsg: '' }); cmodel = new Ext.grid.ColumnModel({ @@ -517,7 +518,7 @@ Ext.onReady( function() { Ext.MessageBox.show({ title: _('ID_CONFIRM'), msg: _('ID_DELETE_INDICATOR_SURE'), - buttons: Ext.MessageBox.YESNOCANCEL, + buttons: Ext.MessageBox.YESNO, fn: function(buttonId) { switch(buttonId) { case 'no': @@ -532,9 +533,6 @@ Ext.onReady( function() { tabActivate.remove(component.id); tabPanel.remove(component); break; - case 'cancel': - flag = true; - break; } }, scope: that @@ -803,6 +801,7 @@ var addTab = function (flag) { selectOnFocus : true, typeAhead : true, autocomplete : true, + width : 90, triggerAction : 'all', mode : 'local', allowBlank : false, @@ -823,7 +822,16 @@ var addTab = function (flag) { maskRe : /([0-9\.]+)$/, maxLength : 9, width : 80, - allowBlank : false + allowBlank : false, + listeners : { + focus : function(tb, e) { + Ext.QuickTips.register({ + target: tb, + title: _('ID_HELP'), + text: _('ID_GOAL_HELP') + }); + } + } } ], listeners: @@ -1070,7 +1078,7 @@ var saveDashboard = function () { var saveAllIndicators = function (DAS_UID) { for (var tab in tabActivate) { - if (tab == 'remove') { + if (tab == 'remove' || tab == 'indexOf' || tab == 'map') { continue; } tabPanel.getItem(tabActivate[tab]).show(); @@ -1085,12 +1093,12 @@ var saveAllIndicators = function (DAS_UID) { for (var index in fieldsTab) { var node = fieldsTab[index]; - if (index == 'remove') { + if (index == 'remove' || index == 'map') { continue; } id = node.id; - if (id.indexOf('fieldSet_') != -1 ) { + if (typeof id == 'undefined' || id.indexOf('fieldSet_') != -1 ) { continue; } id = id.split('_'); From 3e52cc6a13bf3876f543c3908abf1bd814e528c1 Mon Sep 17 00:00:00 2001 From: Dante Date: Mon, 6 Apr 2015 08:38:30 -0400 Subject: [PATCH 08/12] deleteing and commenting echos and print_rs in code --- workflow/engine/classes/class.indicatorsCalculator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workflow/engine/classes/class.indicatorsCalculator.php b/workflow/engine/classes/class.indicatorsCalculator.php index 1dcf45d98..23edaf60f 100644 --- a/workflow/engine/classes/class.indicatorsCalculator.php +++ b/workflow/engine/classes/class.indicatorsCalculator.php @@ -97,7 +97,6 @@ class indicatorsCalculator $connection = $this->pdoConnection(); $result = $this->pdoExecutorWithConnection($sqlString, array(), $connection); $result2 = $this->pdoExecutorWithConnection("select @median", array(), $connection); - print_r($result2); if (sizeof($result) > 0) { $returnValue = current(reset($result2)); } @@ -624,11 +623,12 @@ class indicatorsCalculator } - public function interpolateQuery($query, $params) { + /* For debug only: + * public function interpolateQuery($query, $params) { $keys = array(); # build a regular expression for each parameter foreach ($params as $key => $value) { - echo "
llave", $key, " -- valor", $value; + echo "
key", $key, " -- value", $value; if (is_string($key)) { $keys[] = '/:'.$key.'/'; } else { @@ -637,7 +637,7 @@ class indicatorsCalculator } $query = preg_replace($keys, $params, $query, 1, $count); return $query; - } + }*/ } From 8daa489e8ed4c980036966a20bc0d3e5e89101a7 Mon Sep 17 00:00:00 2001 From: Brayan Pereyra Date: Mon, 6 Apr 2015 09:54:29 -0400 Subject: [PATCH 09/12] PM-642 Directorio shared ya viene creado y con permisos --- workflow/engine/controllers/installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/controllers/installer.php b/workflow/engine/controllers/installer.php index 76b32e2ce..3b2e5da94 100755 --- a/workflow/engine/controllers/installer.php +++ b/workflow/engine/controllers/installer.php @@ -322,7 +322,7 @@ class Installer extends Controller if (is_dir( $aux['dirname'] )) { if (! file_exists( $_REQUEST['pathLogFile'] )) { @file_put_contents( $_REQUEST['pathLogFile'], '' ); - chmod($_REQUEST['pathShared'], 0770); + @chmod($_REQUEST['pathShared'], 0770); } } } From b1635a3f48797b6d4d229f9cecef34a34eab3fde Mon Sep 17 00:00:00 2001 From: Dante Date: Mon, 6 Apr 2015 10:22:43 -0400 Subject: [PATCH 10/12] PDO - host without port correction --- workflow/engine/classes/class.indicatorsCalculator.php | 4 +--- .../engine/templates/strategicDashboard/viewDashboard.html | 1 - .../engine/templates/strategicDashboard/viewDashboardIE.html | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/workflow/engine/classes/class.indicatorsCalculator.php b/workflow/engine/classes/class.indicatorsCalculator.php index 23edaf60f..2e42a0297 100644 --- a/workflow/engine/classes/class.indicatorsCalculator.php +++ b/workflow/engine/classes/class.indicatorsCalculator.php @@ -518,11 +518,9 @@ class indicatorsCalculator G::loadClass('wsTools'); $currentWS = defined('SYS_SYS') ? SYS_SYS : 'Wokspace Undefined'; $workSpace = new workspaceTools($currentWS); - $host = $workSpace->dbHost; - $arrayHost = split(":", $workSpace->dbHost); $host = "host=".$arrayHost[0]; - $port = sizeof($arrayHost) > 0 ? ";port=".$arrayHost[1] : ""; + $port = count($arrayHost) > 1 ? ";port=".$arrayHost[1] : ""; $db = ";dbname=".$workSpace->dbName; $user = $workSpace->dbUser; $pass = $workSpace->dbPass; diff --git a/workflow/engine/templates/strategicDashboard/viewDashboard.html b/workflow/engine/templates/strategicDashboard/viewDashboard.html index 72a63c3b4..ed4035b28 100644 --- a/workflow/engine/templates/strategicDashboard/viewDashboard.html +++ b/workflow/engine/templates/strategicDashboard/viewDashboard.html @@ -38,7 +38,6 @@ G_STRING['{$index}'] = "{$option}"; {/foreach} - diff --git a/workflow/engine/templates/strategicDashboard/viewDashboardIE.html b/workflow/engine/templates/strategicDashboard/viewDashboardIE.html index c0e168689..0029658b1 100644 --- a/workflow/engine/templates/strategicDashboard/viewDashboardIE.html +++ b/workflow/engine/templates/strategicDashboard/viewDashboardIE.html @@ -7,7 +7,7 @@
- //Change xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + For better compatibility with Internet Explorer, a new tab with the KPIs has been opened. Please select this tab on the tab list above to see all the KPI's functionality.
From e851d3b0b780c9e38e5e1973aadeaf431f890a36 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Mon, 6 Apr 2015 10:23:47 -0400 Subject: [PATCH 11/12] IMPROVEMENT --- workflow/engine/classes/class.pmDynaform.php | 38 +++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/workflow/engine/classes/class.pmDynaform.php b/workflow/engine/classes/class.pmDynaform.php index 4d7138c8c..52d6fa84c 100644 --- a/workflow/engine/classes/class.pmDynaform.php +++ b/workflow/engine/classes/class.pmDynaform.php @@ -207,18 +207,13 @@ class pmDynaform if ($this->lang === null && $key === "language" && isset($json->language)) { $this->lang = $json->language; } - if ($key === "label" && isset($json->label) && $this->langs !== null && isset($this->langs->{$this->lang})) { - $langs = $this->langs->{$this->lang}->Labels; - foreach ($langs as $langsValue) { - if ($json->label === $langsValue->msgid) - $json->label = $langsValue->msgstr; - } - } - if ($key === "title" && isset($json->title) && $this->langs !== null && isset($this->langs->{$this->lang})) { - $langs = $this->langs->{$this->lang}->Labels; - foreach ($langs as $langsValue) { - if ($json->title === $langsValue->msgid) - $json->title = $langsValue->msgstr; + 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})) { + $langs = $this->langs->{$this->lang}->Labels; + foreach ($langs as $langsValue) { + if ($json->{$key} === $langsValue->msgid) + $json->{$key} = $langsValue->msgstr; + } } } } @@ -644,9 +639,26 @@ class pmDynaform } if (!$sw1 && !$sw2) { if ($key === "label") { - $json->label; array_push($this->dyn_conten_labels, $json->label); } + if ($key === "hint") { + array_push($this->dyn_conten_labels, $json->hint); + } + if ($key === "placeholder") { + array_push($this->dyn_conten_labels, $json->placeholder); + } + if ($key === "validateMessage") { + array_push($this->dyn_conten_labels, $json->validateMessage); + } + if ($key === "alternateText") { + array_push($this->dyn_conten_labels, $json->alternateText); + } + if ($key === "comment") { + array_push($this->dyn_conten_labels, $json->comment); + } + if ($key === "alt") { + array_push($this->dyn_conten_labels, $json->alt); + } } } } From 120100d6657c120387680d93ba17cb1491cf5f55 Mon Sep 17 00:00:00 2001 From: Dante Date: Mon, 6 Apr 2015 10:57:01 -0400 Subject: [PATCH 12/12] adding all indicators formulae --- .../classes/class.indicatorsCalculator.php | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/workflow/engine/classes/class.indicatorsCalculator.php b/workflow/engine/classes/class.indicatorsCalculator.php index 2e42a0297..c4fa95bd1 100644 --- a/workflow/engine/classes/class.indicatorsCalculator.php +++ b/workflow/engine/classes/class.indicatorsCalculator.php @@ -373,29 +373,60 @@ class indicatorsCalculator '$graph2' as graph2Type, '$freq2' as frequency2Type,"; + $params = Array(); + switch ($indicatorType) { + //process inefficience + case "1020": + $calcField = "$graphConfigurationString 100 * SUM(TOTAL_TIME_BY_TASK) / SUM(CONFIGURED_TASK_TIME) as value"; + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::USER + , $indicatorProcessId, $periodicity + , $initDate, $endDate + , $calcField, $params); + break; + //employee inefficience + case "1040": + $calcField = "$graphConfigurationString 100 * SUM(TOTAL_TIME_BY_TASK) / SUM(CONFIGURED_TASK_TIME) as value"; + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::USER + , $indicatorProcessId, $periodicity + , $initDate, $endDate + , $calcField, $params); + break; //overdue case "1050": $calcField = "$graphConfigurationString 100 * SUM(TOTAL_CASES_OVERDUE) / SUM(TOTAL_CASES_ON_TIME + TOTAL_CASES_OVERDUE) as value"; + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::USER + , $indicatorProcessId, $periodicity + , $initDate, $endDate + , $calcField, $params); break; //new cases case "1060": $calcField = "$graphConfigurationString 100 * SUM(TOTAL_CASES_IN) / SUM(TOTAL_CASES_ON_TIME + TOTAL_CASES_OVERDUE) as value"; + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::PROCESS + , $indicatorProcessId, $periodicity + , $initDate, $endDate + , $calcField, $params); break; //completed case "1070": $calcField = "$graphConfigurationString 100 * SUM(TOTAL_CASES_OUT) / SUM(TOTAL_CASES_ON_TIME + TOTAL_CASES_OVERDUE) as value"; + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::PROCESS + , $indicatorProcessId, $periodicity + , $initDate, $endDate + , $calcField, $params); + break; + case "1080": + $calcField = "$graphConfigurationString 100 * SUM(TOTAL_CASES_OPEN) / SUM(TOTAL_CASES_ON_TIME + TOTAL_CASES_OVERDUE) as value"; + $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::PROCESS + , $indicatorProcessId, $periodicity + , $initDate, $endDate + , $calcField, $params); break; default: throw new Exception(" The indicator id '$indicatorId' with type $indicatorType hasn't an associated operation."); } - $params = Array(); - $sqlString = $this->indicatorsParamsQueryBuilder(IndicatorDataSourcesEnum::PROCESS - , $indicatorProcessId, $periodicity - , $initDate, $endDate - , $calcField, $params); - $retval = $this->pdoExecutor($sqlString, $params); //$returnValue = $this->propelExecutor($sqlString); return $retval; @@ -476,38 +507,7 @@ class indicatorsCalculator return $retval; } - /*private function propelExecutor($sqlString) { - $con = Propel::getConnection(self::$connectionName); - $qry = $con->PrepareStatement($sqlString); - try { - $dataSet = $qry->executeQuery(); - } catch (Exception $e) { - throw new Exception("Can't execute query " . $sqlString); - } - - $rows = Array(); - while ($dataSet->next()) { - $rows[] = $dataSet->getRow(); - } - return $rows; - } -*/ private function pdoExecutor($sqlString, $params) { - /*G::loadClass('wsTools'); - $currentWS = defined('SYS_SYS') ? SYS_SYS : 'Wokspace Undefined'; - $workSpace = new workspaceTools($currentWS); - $host = $workSpace->dbHost; - $db = $workSpace->dbName; - $user = $workSpace->dbUser; - $pass = $workSpace->dbPass; - - - $dbh = new PDO("mysql:host=".$host.";dbname=$db;charset=utf8", $user, $pass); - - $statement = $dbh->prepare($sqlString); - - $statement->execute($params); - $result = $statement->fetchAll(PDO::FETCH_ASSOC); */ $connection = $this->pdoConnection (); $result = $this->pdoExecutorWithConnection($sqlString, $params, $connection);