diff --git a/regional-sales.js b/regional-sales.js index 5e06031..19c1436 100644 --- a/regional-sales.js +++ b/regional-sales.js @@ -42,14 +42,18 @@ function onRegionalSales() { $('.row-offcanvas').toggleClass('active'); }); - $('#end-date').kendoDatePicker({ - value: new Date(1998, 7, 1), - change: onCriteriaChange - }) - $('#start-date').kendoDatePicker({ value: new Date(1996, 0, 1), - change: onCriteriaChange + min: new Date(1996, 0, 1), + max: new Date(1998, 5, 30), + change: startChange + }) + + $('#end-date').kendoDatePicker({ + value: new Date(1998, 7, 9), + min: new Date(1996, 0, 1), + max: new Date(1998, 7, 9), + change: endChange }) $("#map").kendoMap({ @@ -403,6 +407,48 @@ function onRegionalSales() { setSparkLinesWidths(); } + function startChange(e) { + var StartDate = $("#start-date").data("kendoDatePicker"); + var EndDate = $("#end-date").data("kendoDatePicker"); + var startDate = StartDate.value(); + var endDate = EndDate.value(); + + if (startDate) { + startDate = new Date(startDate); + startDate.setDate(startDate.getDate()); + EndDate.min(startDate); + } else if (endDate) { + StartDate.max(new Date(endDate)); + } else { + endDate = new Date(); + StartDate.max(endDate); + EndDate.min(endDate); + } + + onCriteriaChange(); + } + + function endChange(e) { + var StartDate = $("#start-date").data("kendoDatePicker"); + var EndDate = $("#end-date").data("kendoDatePicker"); + var startDate = StartDate.value(); + var endDate = EndDate.value(); + + if (endDate) { + endDate = new Date(endDate); + endDate.setDate(endDate.getDate()); + StartDate.max(endDate); + } else if (startDate) { + EndDate.min(new Date(startDate)); + } else { + endDate = new Date(); + StartDate.max(endDate); + EndDate.min(endDate); + } + + onCriteriaChange(); + } + function listCustomers(country) { $("#countryName").text(country); var companyNames = ""; diff --git a/team-efficiency.html b/team-efficiency.html index cc23424..e5f3cca 100644 --- a/team-efficiency.html +++ b/team-efficiency.html @@ -2,14 +2,14 @@

Team efficiency

- - - + + +
- - - + + +
@@ -43,8 +43,11 @@ -
+
+
+
No data available
+

Representative orders - schedule

diff --git a/team-efficiency.js b/team-efficiency.js index 793fe0b..00d17c6 100644 --- a/team-efficiency.js +++ b/team-efficiency.js @@ -26,14 +26,18 @@ function onTeamEfficiency() { }); function initWidgets() { - $("#StartDate").kendoDatePicker({ - value: new Date(1996, 0, 1), - change: onCriteriaChange + $("#StartDateTeamEff").kendoDatePicker({ + value: new Date(1997, 0, 1), + min: new Date(1996, 0, 1), + max: new Date(1997, 5, 30), + change: startChange }) - $("#EndDate").kendoDatePicker({ - value: new Date(1998, 7, 1), - change: onCriteriaChange + $("#EndDateTeamEff").kendoDatePicker({ + value: new Date(1997, 5, 30), + min: new Date(1997, 0, 1), + max: new Date(1998, 5, 30), + change: endChange }) $("#employees-list").kendoListView({ @@ -104,18 +108,14 @@ function onTeamEfficiency() { autoBind: false, dataBound: onAverageSalesDataBound, dataSource: { - transport: { - read: function (options) { - var result = $.grep(employeeAverageSales, function (e) { - return e.EmployeeID == options.data.EmployeeID; - }); - options.success(result); + data: employeeAverageSales, + schema:{ + model:{ + fields:{ + Date: {type: "date"} + } } - }, - aggregate: [{ - field: "EmployeeSales", - aggregate: "average" - }] + } }, series: [{ type: "line", @@ -166,19 +166,30 @@ function onTeamEfficiency() { dataSource: { transport: { read: function (options) { - var result; - var startDate = options.data.startDate; - var endDate = options.data.endDate; + var StartDateTeamEff = options.data.StartDateTeamEff; + var EndDateTeamEff = options.data.EndDateTeamEff; var employee = $.grep(employeeAndTeamSales, function (e) { return e.EmployeeID == options.data.EmployeeID; })[0]; - options.success(employee.Sales); + options.success($.grep(employee.Sales, function(e){ + var date = kendo.parseDate(e.Date); + if((date>StartDateTeamEff)&&(date