Improvement class indicator calculator
- change DATEDIFF - TIMEDIFF
This commit is contained in:
@@ -513,9 +513,9 @@ class indicatorsCalculator
|
||||
$params[':usrUid'] = $usrUid;
|
||||
|
||||
$sqlString = "SELECT
|
||||
COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS OVERDUE,
|
||||
COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) > 0 ) , 0 ) AS ONTIME,
|
||||
COALESCE( SUM( DATEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 ) , 0 ) AS ATRISK
|
||||
COALESCE( SUM( TIMEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS OVERDUE,
|
||||
COALESCE( SUM( TIMEDIFF( DEL_RISK_DATE , NOW( ) ) > 0 ) , 0 ) AS ONTIME,
|
||||
COALESCE( SUM( TIMEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 ) , 0 ) AS ATRISK
|
||||
FROM LIST_INBOX
|
||||
WHERE USR_UID = :usrUid
|
||||
AND APP_STATUS = 'TO_DO'
|
||||
@@ -534,9 +534,9 @@ class indicatorsCalculator
|
||||
APP_TAS_TITLE AS taskTitle,
|
||||
APP_PRO_TITLE AS proTitle,
|
||||
|
||||
COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS overdue,
|
||||
COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) > 0 ) , 0 ) AS onTime,
|
||||
COALESCE( SUM( DATEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 ) , 0 ) AS atRisk
|
||||
COALESCE( SUM( TIMEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS overdue,
|
||||
COALESCE( SUM( TIMEDIFF( DEL_RISK_DATE , NOW( ) ) > 0 ) , 0 ) AS onTime,
|
||||
COALESCE( SUM( TIMEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 ) , 0 ) AS atRisk
|
||||
FROM LIST_INBOX
|
||||
WHERE USR_UID = :usrUid
|
||||
AND APP_STATUS = 'TO_DO'
|
||||
@@ -561,8 +561,8 @@ class indicatorsCalculator
|
||||
|
||||
if (is_array($result) && isset($result[0])) {
|
||||
$response['overdue'] = $result[0]['OVERDUE'];
|
||||
$response['atRisk'] = $result[0]['ONTIME'];
|
||||
$response['onTime'] = $result[0]['ATRISK'];
|
||||
$response['atRisk'] = $result[0]['ATRISK'];
|
||||
$response['onTime'] = $result[0]['ONTIME'];
|
||||
|
||||
$total = $response['overdue'] + $response['atRisk'] + $response['onTime'];
|
||||
if ($total != 0) {
|
||||
@@ -578,20 +578,20 @@ class indicatorsCalculator
|
||||
$result[$key]['overdue'] = $value['overdue'];
|
||||
$result[$key]['atRisk'] = $value['atRisk'];
|
||||
$result[$key]['onTime'] = $value['onTime'];
|
||||
$result[$key]['percentageOverdue'] = 0;
|
||||
$result[$key]['percentageAtRisk'] = 0;
|
||||
$result[$key]['percentageOnTime'] = 0;
|
||||
$result[$key]['percentageTotalOverdue'] = 0;
|
||||
$result[$key]['percentageTotalAtRisk'] = 0;
|
||||
$result[$key]['percentageTotalOnTime'] = 0;
|
||||
$result[$key]['percentageOverdue'] = 0;
|
||||
$result[$key]['percentageAtRisk'] = 0;
|
||||
$result[$key]['percentageOnTime'] = 0;
|
||||
$result[$key]['percentageTotalOverdue'] = 0;
|
||||
$result[$key]['percentageTotalAtRisk'] = 0;
|
||||
$result[$key]['percentageTotalOnTime'] = 0;
|
||||
$total = $value['overdue'] + $value['onTime'] + $value['atRisk'];
|
||||
if ($total != 0) {
|
||||
$result[$key]['percentageOverdue'] = ($value['overdue']*100)/$total;
|
||||
$result[$key]['percentageAtRisk'] = ($value['atRisk']*100)/$total;
|
||||
$result[$key]['percentageOnTime'] = ($value['onTime']*100)/$total;
|
||||
$result[$key]['percentageTotalOverdue'] = $response['overdue'] != 0 ? ($value['overdue']*100)/$response['overdue']: 0;
|
||||
$result[$key]['percentageTotalAtRisk'] = $response['atRisk'] != 0 ? ($value['atRisk']*100)/$response['atRisk'] : 0;
|
||||
$result[$key]['percentageTotalOnTime'] = $response['onTime'] != 0 ? ($value['onTime']*100)/$response['onTime']: 0;
|
||||
$result[$key]['percentageTotalOverdue'] = $response['overdue'] != 0 ? ($value['overdue']*100)/$response['overdue']: 0;
|
||||
$result[$key]['percentageTotalAtRisk'] = $response['atRisk'] != 0 ? ($value['atRisk']*100)/$response['atRisk'] : 0;
|
||||
$result[$key]['percentageTotalOnTime'] = $response['onTime'] != 0 ? ($value['onTime']*100)/$response['onTime']: 0;
|
||||
}
|
||||
}
|
||||
$response['dataList'] = $result;
|
||||
|
||||
Reference in New Issue
Block a user