Merged in dashboards2 (pull request #2130)

using calendar days for configured task time
This commit is contained in:
Julio Cesar Laura Avendaño
2015-05-08 11:10:26 -04:00
7 changed files with 86 additions and 56 deletions

View File

@@ -22,6 +22,7 @@ ViewDashboardPresenter.prototype.userDashboardsViewModel = function(data) {
//if null data is returned we default to an empty array
if (data == null) { data = []; }
var returnList = [];
var hasFavorite = false;
$.each(data, function(index, originalObject) {
var map = {
"DAS_TITLE" : "title",
@@ -29,8 +30,17 @@ ViewDashboardPresenter.prototype.userDashboardsViewModel = function(data) {
"DAS_FAVORITE" : "isFavorite"
};
var newObject = that.helper.merge(originalObject, {}, map);
if (newObject.isFavorite == 1) {
hasFavorite = true;
}
returnList.push(newObject);
});
//if no favorite is selected, the first one is selected.
if (!hasFavorite && returnList.length > 0 ) {
returnList[0].isFavorite = 1;
}
return returnList;
};
@@ -88,12 +98,12 @@ ViewDashboardPresenter.prototype.dashboardIndicatorsViewModel = function(data) {
//rounding
newObject.comparative = Math.round(newObject.comparative*100)/100;
newObject.comparative = ((newObject.comparative > 0)? "+": "") + newObject.comparative;
newObject.comparative = ((newObject.comparative > 0) ? "+": "") + newObject.comparative;
newObject.percentComparative = (newObject.percentComparative != '--')
? '(' + newObject.percentComparative + '%)'
: "";
newObject.percentComparative = (newObject.comparative == 0)
newObject.percentComparative = (newObject.comparative == 0 && newObject.percentComparative != '')
? "(0%)"
: newObject.percentComparative;
@@ -255,7 +265,8 @@ ViewDashboardPresenter.prototype.peiViewModel = function(data) {
var newObject = that.helper.merge(originalObject, {}, map);
graphData.push(newObject);
originalObject.efficiencyIndexToShow = that.roundedIndicatorValue(originalObject.efficiencyIndex);
originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost);
//rounded to 1 decimal
originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost * 10) / 10;
originalObject.indicatorId = data.id;
originalObject.json = JSON.stringify(originalObject);
});
@@ -266,7 +277,7 @@ ViewDashboardPresenter.prototype.peiViewModel = function(data) {
this.makeShortLabel(graphData, 10);
retval.dataToDraw = this.adaptGraphData(graphData);
retval.inefficiencyCostToShow = Math.round(retval.inefficiencyCost);
retval.inefficiencyCostToShow = Math.round(retval.inefficiencyCost * 10) / 10;
retval.efficiencyIndexToShow = that.roundedIndicatorValue(retval.efficiencyIndex);
return retval;
};
@@ -284,7 +295,7 @@ ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
};
var newObject = that.helper.merge(originalObject, {}, map);
graphData.push(newObject);
originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost);
originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost * 10)/10;
originalObject.efficiencyIndexToShow = that.roundedIndicatorValue(originalObject.efficiencyIndex);
originalObject.indicatorId = data.id;
originalObject.json = JSON.stringify(originalObject);
@@ -295,7 +306,7 @@ ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
this.makeShortLabel(graphData, 10);
retval.dataToDraw = this.adaptGraphData(graphData);
retval.inefficiencyCostToShow = Math.round(retval.inefficiencyCost);
retval.inefficiencyCostToShow = Math.round(retval.inefficiencyCost * 10) / 10;
retval.efficiencyIndexToShow = that.roundedIndicatorValue(retval.efficiencyIndex);
return retval;
};
@@ -418,7 +429,7 @@ ViewDashboardPresenter.prototype.returnIndicatorSecondLevelPei = function(modelD
"deviationTime" : "dispersion"
};
var newObject = that.helper.merge(originalObject, {}, map);
originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost);
originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost * 10) / 10;
originalObject.efficiencyIndexToShow = that.roundedIndicatorValue(originalObject.efficiencyIndex);
originalObject.deviationTimeToShow = Math.round(originalObject.deviationTime);
originalObject.rankToShow = originalObject.rank + "/" + modelData.length;
@@ -445,7 +456,7 @@ ViewDashboardPresenter.prototype.returnIndicatorSecondLevelUei = function(modelD
"deviationTime" : "dispersion"
};
var newObject = that.helper.merge(originalObject, {}, map);
originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost);
originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost * 10) / 10;
originalObject.efficiencyIndexToShow = that.roundedIndicatorValue(originalObject.efficiencyIndex);
originalObject.deviationTimeToShow = Math.round(originalObject.deviationTime);
originalObject.rankToShow = originalObject.rank + "/" + modelData.length;

View File

@@ -535,7 +535,9 @@ var defaultEndDate = function () {
var fillDashboardsList = function (presenterData) {
if (presenterData == null || presenterData.length == 0) {
$('#dashboardsList').append(G_STRING['ID_NO_DATA_TO_DISPLAY']);
$('#dashboardMessage').text(G_STRING['ID_GRID_PAGE_NO_DASHBOARD_MESSAGE']);
$('#titleH4').text(G_STRING['ID_GRID_PAGE_NO_DASHBOARD_MESSAGE']);
$('#compareIndicators').hide();
}
_.templateSettings.variable = "dashboard";
var template = _.template ($("script.dashboardButtonTemplate").html())

View File

@@ -39,7 +39,7 @@ WHERE
APPLICATION.APP_INIT_DATE BETWEEN CAST(@INIT_DATE AS DATETIME) AND CAST(@FINISH_DATE AS DATETIME)
GROUP BY APPLICATION.PRO_UID;
#TODO task duration should be calculated with the calendar
UPDATE PRO_REPORTING
SET PRO_REPORTING.CONFIGURED_PROCESS_TIME = (
SELECT SUM(if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*24), TASK.TAS_DURATION))

View File

@@ -39,11 +39,15 @@ SELECT
count(if(ACV.DEL_DELAY_DURATION > 0, 1, NULL)) AS TOTAL_CASES_OVERDUE,
count(if(ACV.DEL_DELAY_DURATION <= 0, 1, NULL)) AS TOTAL_CASES_ON_TIME
FROM
APP_CACHE_VIEW AS ACV
APP_CACHE_VIEW AS ACV
WHERE
ACV.DEL_INIT_DATE BETWEEN CAST(@INIT_DATE AS DATETIME) AND CAST(@FINISH_DATE AS DATETIME)
GROUP BY ACV.USR_UID , ACV.TAS_UID , ACV.PRO_UID;
DELETE USR_REPORTING
FROM USR_REPORTING
INNER JOIN TASK ON TASK.TAS_UID = USR_REPORTING.TAS_UID
WHERE TASK.TAS_TYPE NOT IN ('NORMAL', 'ADHOC');
UPDATE USR_REPORTING
INNER JOIN
@@ -52,10 +56,16 @@ ON USR_REPORTING.USR_UID = USERS.USR_UID
SET USR_REPORTING.USER_HOUR_COST = USERS.USR_COST_BY_HOUR;
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*24), TASK.TAS_DURATION)
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 *
(IF ((SELECT CA.CALENDAR_UID FROM CALENDAR_ASSIGNMENTS AS CA WHERE CA.OBJECT_UID = TASK.TAS_UID limit 1) IS NOT NULL,
(SELECT AVG(TIMEDIFF(STR_TO_DATE(CBH.CALENDAR_BUSINESS_END, '%H:%i'), STR_TO_DATE(CBH.CALENDAR_BUSINESS_START, '%H:%i')))/10000
FROM CALENDAR_ASSIGNMENTS AS CA, CALENDAR_BUSINESS_HOURS AS CBH
WHERE CA.OBJECT_UID = TASK.TAS_UID
AND CA.CALENDAR_UID = CBH.CALENDAR_UID
GROUP BY CA.CALENDAR_UID LIMIT 1) ,24)))
,TASK.TAS_DURATION)

View File

@@ -41,26 +41,27 @@ class Dashboard {
$resp = array();
$dashboards = $this->getDashboardsUidByUser($usr_uid);
$existFavorite = false;
$cont = 0;
foreach($dashboards as $i=>$x) {
//$resp[$i] = $this->getDashboard($x['DAS_UID']);
$dashboardUser = $this->getDashboard($x['DAS_UID']);
if ($dashboardUser['DAS_STATUS'] == 0) {
continue;
}
$resp[$i] = $dashboardUser;
$resp[$cont] = $dashboardUser;
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
$dashConfig = $Dashboard->getConfig($usr_uid);
$resp[$i]['DAS_FAVORITE'] = 0;
$resp[$cont]['DAS_FAVORITE'] = 0;
foreach ($dashConfig as $dashId=>$dashData) {
if($dashId == $x['DAS_UID'] ) {
$resp[$i]['DAS_FAVORITE'] = $dashData['dashFavorite'];
$resp[$cont]['DAS_FAVORITE'] = $dashData['dashFavorite'];
if ($dashData['dashFavorite']==1) {
$existFavorite = true;
}
}
}
$cont++;
}
//if no favorite is set, the default favorite is the first one
if ($existFavorite == false && $resp != null && sizeof($resp)>0) {
$resp[0]['DAS_FAVORITE'] = 1;

View File

@@ -170,7 +170,9 @@
</script>
<script type="text/template" class="specialIndicatorDetail">
<div class="process-div well hideme detail-button-selector" data-gs-no-resize="true"
<div class="process-div well hideme detail-button-selector"
data-gs-no-resize="true"
style="cursor:pointer;"
id="detailData-<%- detailData.uid %>"
data-indicator-id="<%- detailData.indicatorId %>"
data-detail-id="<%- detailData.uid %>"
@@ -179,36 +181,12 @@
data-detail-cost="<%- detailData.inefficiencyCost%>"
data-detail-name="<%- detailData.name %>"
>
<div class="col-lg-12 vcenter-task">
<a href="#" class="process-button">
<div class="col-xs-5 text-left title-process">
<div class="small grey detail-title-selector"> <%- detailData.name %></div>
</div>
<div class="col-xs-3 text-center ">
<div class="blue"><%- detailData.efficiencyIndexToShow%></div>
<div class="small grey detail-efficiency-selector ellipsis"></div>
</div>
<div class="col-xs-3 text-center ">
<div class="red detail-cost-number-selector">{$unitCost}<%- detailData.inefficiencyCostToShow %></div>
<div class="small grey detail-cost-selector ellipsis"></div>
</div>
<div class="col-xs-1 text-right arrow"><i class="fa fa-chevron-right fa-fw"></i></div>
</a>
</div>
<div class="clearfix"></div>
</div>
</script>
<script type="text/template" class="specialIndicatorSecondViewDetailUei">
<div class="process-div well hideme detail-button-selector-uei" data-gs-no-resize="true"
id="detailData-<%- detailData.uid %>"
data-indicator-id="<%- detailData.indicatorId %>"
data-detail-id="<%- detailData.uid %>">
<div class="panel-heading greenbg">
<div class="col-xs-12 text-center detail-title-selector">
<i class="fa fa-tasks fa-fw"></i>
<span id="usrName"><%- detailData.name %> </span>
<span>(<%- detailData.rankToShow %>)</span>
<div class="col-xs-11 text-center detail-title-selector">
<div class="ellipsis"><%- detailData.name %> </div>
</div>
<div class="col-xs-1 text-center detail-title-selector">
<i class="fa fa-chevron-right fa-fw"></i>
</div>
<div class="clearfix"></div>
</div>
@@ -219,7 +197,36 @@
<div class="smallB grey detail-efficiency-selector ellipsis"></div>
</div>
<div class="col-xs-6 ">
<div class="small detail-cost-number-selector">{$unitCost}<%- detailData.inefficiencyCostToShow%></div>
<div class="small detail-cost-number-selector">{$unitCost}&nbsp;<%- detailData.inefficiencyCostToShow%></div>
<div class="smallB grey detail-cost-selector ellipsis"></div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</script>
<script type="text/template" class="specialIndicatorSecondViewDetailUei">
<div class="process-div well hideme detail-button-selector-uei" data-gs-no-resize="true"
id="detailData-<%- detailData.uid %>"
data-indicator-id="<%- detailData.indicatorId %>"
data-detail-id="<%- detailData.uid %>">
<div class="panel-heading greenbg">
<div class="col-xs-12 text-center detail-title-selector ellipsis">
<span id="usrName"><%- detailData.name %> </span>
(Ranking: <%- detailData.rankToShow %>)
</div>
<div class="clearfix"></div>
</div>
<div class="text-center huge">
<div class="col-xs-12 vcenter-task">
<div class="col-xs-6 ">
<div class="blue small"><%- detailData.efficiencyIndexToShow%></div>
<div class="smallB grey detail-efficiency-selector ellipsis"></div>
</div>
<div class="col-xs-6 ">
<div class="small detail-cost-number-selector">{$unitCost}&nbsp;<%- detailData.inefficiencyCostToShow%></div>
<div class="smallB grey detail-cost-selector ellipsis"></div>
</div>
</div>
@@ -247,7 +254,7 @@
<div class="smallB grey detail-efficiency-selector ellipsis"></div>
</div>
<div class="col-xs-6 ">
<div class="small detail-cost-number-selector">{$unitCost}<%- detailData.inefficiencyCostToShow%></div>
<div class="small detail-cost-number-selector">{$unitCost}&nbsp;<%- detailData.inefficiencyCostToShow%></div>
<div class="smallB grey detail-cost-selector ellipsis"></div>
</div>
</div>
@@ -358,12 +365,11 @@
<h4 id="titleH4" class="header-dashboard"></h4>
<div class="pull-right dashboard-right container-fluid">
<div class="row pull-left">
<div id="compareIndicators" class="row pull-left">
<div class="span4 pull-left">
<h5 class="pull-left">{translate label="ID_DASH_COMPARE_MONTH"}:</h5>
</div>
<div class="span4 pull-left">
<select id="year" class="form-control pull-right ">
{literal}
@@ -402,7 +408,7 @@
<div class="clearfix"></div>
<div class="collapse" id="collapseExample">
<div class="well">
<p class="text-center">{translate label="ID_DASH_CLICK_TO_VIEW"}</p>
<p id="dashboardMessage" class="text-center">{translate label="ID_DASH_CLICK_TO_VIEW"}</p>
<p>
<!-- Split button -->
<div id="dashboardsList">

View File

@@ -1176,7 +1176,7 @@ function saveUser()
}
}
if (!Ext.getCmp('USR_COST_BY_HOUR').isValid()) {
PMExt.warning(_('ID_ERROR'), _('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', _('ID_COST_BY_HOUR')));
PMExt.warning(_('ID_ERROR'), _('ID_INVALID_VALUE_EXPECTING_POSITIVE_DECIMAL', _('ID_COST_BY_HOUR')));
Ext.getCmp('USR_COST_BY_HOUR').focus(true,10);
return false;
}