Scheduler, pb to be fixed if the resource and the lease are not matching = disabled...
[unfold.git] / plugins / scheduler2 / static / js / scheduler-helpers.js
index d6f3224..7275b75 100755 (executable)
@@ -46,20 +46,6 @@ function schedulerCloneArray(originalArray) {
     return clonedArray;\r
 }\r
 \r
-function schedulerGetSlots(slotSpan) {\r
-    if (slotSpan == 0) slotSpan = 10;\r
-    var slots = [];\r
-    var d = new Date(2014, 1, 1, 0, 0, 0, 0);\r
-    var i = 0;\r
-    while (d.getDate() == 1) {\r
-        var tmpTime = schedulerPadStr(d.getHours()) + ':' + schedulerPadStr(d.getMinutes());\r
-        slots.push({ id: i, time: tmpTime });\r
-        d = schedulerAddMinutes(d, slotSpan);\r
-        i++;\r
-    }\r
-    return slots;\r
-}\r
-\r
 function schedulerGetLeases(slotSpan, granularity) {\r
     granularity = granularity / 60;\r
     if (slotSpan == 0) slotSpan = 10;\r
@@ -127,6 +113,7 @@ function schedulerFindDuration(startTime, endTime, granularity) {
 //\r
 // Set Select - Free Slots *******Start\r
 function schedulerSelectSlot(slotId, rowIndex, resourceIndex) {\r
+    console.log('timeslot selected');\r
     _schedulerSetStatusSlot(slotId, rowIndex, resourceIndex, 'selected');\r
 }\r
 function schedulerFreeSlot(slotId, rowIndex, resourceIndex) {\r
@@ -136,6 +123,7 @@ function schedulerFreeSlot(slotId, rowIndex, resourceIndex) {
 function _schedulerSetStatusSlot(slotId, rowIndex, resourceIndex, classText) {\r
     var tmpVS = SchedulerDataViewData[rowIndex].leases[slotId];  // for the display\r
     var tmpS = SchedulerData[resourceIndex].leases[slotId];     // for the data\r
+    console.log(SchedulerData[resourceIndex].id);\r
     tmpVS.status = classText;\r
     tmpS.status = classText;\r
     //select other from the group in the same granularity\r
@@ -146,7 +134,7 @@ function _schedulerSetStatusSlot(slotId, rowIndex, resourceIndex, classText) {
     for (var s = 0; s < maxg; s++) {\r
         if (tmpVS.groupIndex != s) {\r
             SchedulerDataViewData[rowIndex].leases[startSlotId].status = classText;\r
-            SchedulerData[rowIndex].leases[startSlotId].status = classText;\r
+            SchedulerData[resourceIndex].leases[startSlotId].status = classText;\r
         }\r
         startSlotId++;\r
     }\r
@@ -185,7 +173,16 @@ function schedulerAddMinutes(date, minutes) {
     return new Date(date.getTime() + minutes * 60000);\r
 }\r
 \r
-function schedulerCompareOnDay(dateOne, dateTwo) {\r
+/**\r
+ * Compares two dates\r
+ *\r
+ * Returns:\r
+ *   0 if they are equal\r
+ *   -1 if the first is less than the second\r
+ *   1 if the first is more than the second\r
+ */\r
+function schedulerCompareOnDay(dateOne, dateTwo)\r
+{\r
     if (dateOne.getYear() == dateTwo.getYear() &&\r
         dateOne.getMonth() == dateTwo.getMonth() &&\r
         dateOne.getDate() == dateTwo.getDate()) {\r
@@ -193,7 +190,7 @@ function schedulerCompareOnDay(dateOne, dateTwo) {
     } else if (dateOne > dateTwo) {\r
         return -1;\r
     } else {\r
-        return 0;\r
+        return 1;\r
     }\r
 \r
-}
\ No newline at end of file
+}\r