|
@@ -3,23 +3,51 @@
|
3
|
3
|
angular.module('appSdk')
|
4
|
4
|
.factory('WeeksBusiness', ['WeeksDataAccess', '$q', function (WeeksDataAccess, $q) {
|
5
|
5
|
|
|
6
|
+ function isDateInCourse(course, date)
|
|
7
|
+ {
|
|
8
|
+ return course.BeginDate < date && course.EndDate > date;
|
|
9
|
+ }
|
|
10
|
+
|
6
|
11
|
var Business = {};
|
7
|
12
|
|
8
|
13
|
Business.formatWeek = function(data)
|
9
|
14
|
{
|
10
|
15
|
data.DayList.forEach(function(day) {
|
|
16
|
+ day.DateTime = new Date(day.DateTime);
|
11
|
17
|
day.CourseList.forEach(function (course) {
|
|
18
|
+
|
|
19
|
+ course.BeginDate = new Date(course.BeginDate);
|
12
|
20
|
var dt = new Date(course.BeginDate);
|
13
|
21
|
var secs = dt.getSeconds() + (60 * dt.getMinutes()) + (60 * 60 * dt.getHours());
|
14
|
22
|
course.BeginPercent = secs / (60 * 60 * 24) * 100;
|
15
|
23
|
course.BeginSeconds = secs;
|
16
|
24
|
|
|
25
|
+ course.EndDate = new Date(course.EndDate);
|
17
|
26
|
dt = new Date(course.EndDate);
|
18
|
27
|
secs = dt.getSeconds() + (60 * dt.getMinutes()) + (60 * 60 * dt.getHours());
|
19
|
28
|
course.EndPercent = secs / (60 * 60 * 24) * 100;
|
20
|
29
|
course.EndSeconds = secs;
|
21
|
30
|
});
|
22
|
31
|
});
|
|
32
|
+ data.DayList.forEach(function(day) {
|
|
33
|
+ day.CourseList.forEach(function (course) {
|
|
34
|
+ course.ParallelCoursesCount = 1;
|
|
35
|
+ course.ParallelCoursesPosition = 0;
|
|
36
|
+ day.CourseList.forEach(function (course2) {
|
|
37
|
+ if (course.Id == course2.Id) {
|
|
38
|
+ return;
|
|
39
|
+ }
|
|
40
|
+ var beginBeforeEndIn = (course2.BeginDate <= course.BeginDate && isDateInCourse(course, course2.EndDate));
|
|
41
|
+ var beginInEndAfter = (course2.EndDate >= course.EndDate && isDateInCourse(course, course2.BeginDate));
|
|
42
|
+ var beginBeforeEndAfter = (course2.BeginDate <= course.BeginDate && course2.EndDate >= course.EndDate);
|
|
43
|
+ var beginInEndIn = (isDateInCourse(course, course2.EndDate) && isDateInCourse(course, course2.BeginDate));
|
|
44
|
+ if (beginBeforeEndIn || beginInEndAfter || beginBeforeEndAfter || beginInEndIn) {
|
|
45
|
+ ++course.ParallelCoursesCount;
|
|
46
|
+ course2.ParallelCoursesPosition = Math.max(course.ParallelCoursesPosition, course2.ParallelCoursesPosition) + 1
|
|
47
|
+ }
|
|
48
|
+ });
|
|
49
|
+ });
|
|
50
|
+ });
|
23
|
51
|
};
|
24
|
52
|
|
25
|
53
|
Business.getWeek = function(data, promise)
|