adding queries for Open Cases vs. Completed Cases dashlet KPI
This commit is contained in:
@@ -34,10 +34,51 @@ Array
|
||||
|
||||
//$this->w = $config['w'];
|
||||
//loadData
|
||||
$thisYear = date('Y');
|
||||
$lastYear = $thisYear -1;
|
||||
$thisMonth = date('M');
|
||||
$lastMonth = date('M', strtotime( "31 days ago") );
|
||||
//print "$thisMonth $lastMonth"; die;
|
||||
|
||||
$todayIni = date('Y-m-d H:i:s', strtotime( "today 00:00:00"));
|
||||
$todayEnd = date('Y-m-d H:i:s', strtotime( "today 23:59:59"));
|
||||
$yesterdayIni = date('Y-m-d H:i:s', strtotime( "yesterday 00:00:00"));
|
||||
$yesterdayEnd = date('Y-m-d H:i:s', strtotime( "yesterday 23:59:59"));
|
||||
$thisWeekIni = date('Y-m-d H:i:s', strtotime( "monday 00:00:00"));
|
||||
$thisWeekEnd = date('Y-m-d H:i:s', strtotime( "sunday 23:59:59"));
|
||||
$previousWeekIni = date('Y-m-d H:i:s', strtotime( "last monday 00:00:00"));
|
||||
$previousWeekEnd = date('Y-m-d H:i:s', strtotime( "last sunday 23:59:59"));
|
||||
|
||||
$thisMonthIni = date('Y-m-d H:i:s', strtotime( "$thisMonth 1st 00:00:00"));
|
||||
$thisMonthEnd = date('Y-m-d H:i:s', strtotime( "$thisMonth last day 23:59:59"));
|
||||
|
||||
$previousMonthIni = date('Y-m-d H:i:s', strtotime( "$lastMonth 1st 00:00:00"));
|
||||
$previousMonthEnd = date('Y-m-d H:i:s', strtotime( "$lastMonth last day 23:59:59"));
|
||||
|
||||
$thisYearIni = date('Y-m-d H:i:s', strtotime( "jan $thisYear 00:00:00"));
|
||||
$thisYearEnd = date('Y-m-d H:i:s', strtotime( "Dec 31 $thisYear 23:59:59"));
|
||||
$previousYearIni = date('Y-m-d H:i:s', strtotime( "jan $lastYear 00:00:00"));
|
||||
$previousYearEnd = date('Y-m-d H:i:s', strtotime( "Dec 31 $lastYear 23:59:59"));
|
||||
|
||||
switch ( $config['DAS_INS_CONTEXT_TIME'] ) {
|
||||
case 'TODAY' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'YESTERDAY' : $dateIni = $yesterdayIni; $dateEnd = $yesterdayEnd; break;
|
||||
case 'THIS_WEEK' : $dateIni = $thisWeekIni; $dateEnd = $thisWeekEnd; break;
|
||||
case 'PREVIOUS_WEEK' : $dateIni = $previousWeekIni; $dateEnd = $previousWeekEnd; break;
|
||||
|
||||
case 'THIS_MONTH' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'PREVIOUS_MONTH' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'THIS_QUARTER' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
case 'PREVIOUS_QUARTER' : $dateIni = $todayIni; $dateEnd = $todayEnd; break;
|
||||
|
||||
case 'THIS_YEAR' : $dateIni = $thisYearIni; $dateEnd = $thisYearEnd; break;
|
||||
case 'PREVIOUS_YEAR' : $dateIni = $previousYearIni; $dateEnd = $previousYearEnd; break;
|
||||
}
|
||||
|
||||
$con = Propel::getConnection("workflow");
|
||||
$stmt = $con->createStatement();
|
||||
$sql = "select count(*) as CANT from APPLICATION where APP_STATUS = 'TO_DO' ";
|
||||
$sql = "select count(*) as CANT from APPLICATION where APP_STATUS in ( 'DRAFT', 'TO_DO' ) ";
|
||||
$sql .= "and APP_CREATE_DATE > '$dateIni' and APP_CREATE_DATE <= '$dateEnd' ";
|
||||
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
@@ -45,16 +86,19 @@ Array
|
||||
|
||||
$stmt = $con->createStatement();
|
||||
$sql = "select count(*) as CANT from APPLICATION where APP_STATUS = 'COMPLETED' ";
|
||||
$sql .= "and APP_CREATE_DATE > '$dateIni' and APP_CREATE_DATE <= '$dateEnd' ";
|
||||
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$casesCompleted = $row['CANT'];
|
||||
if ( $casesCompleted + $casesTodo != 0 ) {
|
||||
$this->value = $casesTodo / ($casesCompleted + $casesTodo)*100;
|
||||
$this->value = $casesCompleted / ($casesCompleted + $casesTodo)*100;
|
||||
}
|
||||
else {
|
||||
$this->value = 0;
|
||||
}
|
||||
$this->open = $casesCompleted;
|
||||
$this->completed = $casesCompleted + $casesTodo;
|
||||
switch ( $config['DAS_INS_CONTEXT_TIME'] ) {
|
||||
case 'TODAY' : $this->centerLabel = 'Today'; break;
|
||||
case 'YESTERDAY' : $this->centerLabel = 'Yesterday'; break;
|
||||
@@ -84,6 +128,8 @@ Array
|
||||
$g->redFrom = 100;
|
||||
$g->redTo = 100;
|
||||
$g->centerLabel = $this->centerLabel;
|
||||
$g->open = $this->open;
|
||||
$g->completed = $this->completed;
|
||||
$g->render();
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,10 @@
|
||||
imagettftext ( $im, 8, 0, $x1, $y1, $black, $fontArial, $textToDisplay );
|
||||
}
|
||||
|
||||
imagettftext ( $im, 9, 0, $cX*0.60, $cY*1.8, $gray, $fontArial, $this->open );
|
||||
imagettftext ( $im, 9, 0, $cX*1.40, $cY*1.8, $gray, $fontArial, $this->completed );
|
||||
|
||||
|
||||
//drawing the arrow, simple way
|
||||
$radiusX = intval($dX * 0.35);
|
||||
$radiusY = intval($dY * 0.35);
|
||||
|
||||
Reference in New Issue
Block a user