README.txt
[gitlive] / Tasks.js
index 97cddd9..c972779 100644 (file)
--- a/Tasks.js
+++ b/Tasks.js
@@ -72,7 +72,8 @@ Tasks = {
                 //print(JSON.stringify(res,null,4))
                 //print([ res.success , res.data.length ]);
                 _this.curTask = (res.success && res.data.length) ? (new Task(res.data[0])) : false;
-                print(JSON.stringify(_this.curTask,null,4));
+                
+                print("Current task:" + JSON.stringify(_this.curTask,null,4));
                 _this.fetchRepo();
             }
             
@@ -82,7 +83,7 @@ Tasks = {
         r.open('GET',
                "http://roojs.com/admin.php/Roo/cash_invoice_entry?_current_task=1"
                ,true, netrc.login, netrc.password  );
-        //print("SEding request");        
+         print("Getting current task: "  +  "http://roojs.com/admin.php/Roo/cash_invoice_entry?_current_task=1");        
         r.send();
         
     },
@@ -132,16 +133,7 @@ Tasks = {
         // using curTask + lastCommit decide what to do.
         this.inQuery = 0;
         //tests:::
-        this.verifyTaskTime();
-        this.verifyTaskProject();
-          
-        
-        
-        
-    },
-    
-    verifyTaskTime : function()
-    {
+       
         // check to see if current task is being planned for too long..
         // you should only enter task, and allow it to span over an hour.
         // if you do the whole day on a task, then it will need to verify with you every so often that you
@@ -159,28 +151,66 @@ Tasks = {
                 
           
          */
-        var now = new Date();
-        if ( this.curTask) {
-            var endoftask = this.activeTask.active_datetime.add(Date.HOUR, this.activeTask.qtyvalue);
-            var max_stretch = now.add(Date.HOUR, 1);
-            if (endoftask > max_stretch) {
-                this.fixEndCurrTask(); //
-                 
-            }
+        
+        if (!this.currTask) {
+             this.promptForTask();
+            return;
+        }
+        
+         if (!this.currTask.project_id) {
+            this.promptForTask();
+            return;
+        }
+        
+        // are we working on the same project!!!!
+        if (this.currTask.project_id != this.commitRepo.project_id) {
+            this.promptForTask();
+            return;
+        }
+  
+        // has the ticket been closed...
+        
+        var is_project=  this.curTask.project_id_code[0] != '*' ;
+        // is there a ticket?
+        if (is_project && !this.currTask.ticket_id) {
+            this.promptForTask();
+            return;
+        }
+        if (is_project && this.currTask.ticket_status) {
+            //TODO - if status is closed.. then we need to prompt..
             
             
         }
         
         
+        // we now working on same project..
+        
+        
+        var now = new Date();
+        
+        print(JSON.stringify(this.curTask));
+        
+        var endoftask = this.curTask.action_datetime.add(Date.HOUR, this.curTask.qtyvalue);
+        print("END OF TASK: " + endoftask);
+        
+        var max_stretch = now.add(Date.HOUR, 1);
+         print("Max stretch: " + max_stretch);
+        if (endoftask > max_stretch) {
+            this.fixEndCurrTask(); //
+            
+        }
+        // still needs to be verified..
+       
+        
         
         
 
         
         if (!this.nextPrompt && this.curTask) {
-            //var use_start = this.curTask.active_datetime < now ? now : 
+            //var use_start = this.curTask.action_datetime < now ? now : 
             // if we have a task, then the next verification should be 1 hour after it started.
             // even if we have only just seen it.. so we could already need verification.
-            this.nextPrompt = this.curTask.active_datetime; // the start time recorded in the database.
+            this.nextPrompt = this.curTask.action_datetime; // the start time recorded in the database.
         }
         
         
@@ -191,11 +221,17 @@ Tasks = {
             
         }
         
+        // ok verified basic time...
+        //let's check to see if project matches..'
+        
         
         
         
     },
     
+    
+    
+    
     //---------- end verifying - now prompting..
     
     
@@ -208,10 +244,16 @@ Tasks = {
         var min = Math.round((eot.format('i')*1) / 15) * 15;
         var reot = Date.parseDate(eot.format('Y-m-d H:') + (min ? min : '00') + ':00', 'Y-m-d H:i:s');
         
-        // how long between start and reot...
-        var hours = (reot - this.curTask.active_datetime) / (60*60 * 1000 );
-                this.updateTask({ qtyvalue : 1 });
+        print("REAL END TIME" + reot.format('Y-m-d H:i:s'))
+        print("Current start time" + this.curTask.action_datetime.format('Y-m-d H:i:s'))
         
+        // how long between start and reot...
+        var hours = (reot - this.curTask.action_datetime) / (60*60 * 1000 );
+        var rounded =  Math.round(hours * 4) / 4.0;
+        print("Rounded : "  + rounded);
+        //return;
+        this.updateTask({ qtyvalue : rounded });
+        this.curTask.qtyvalue = rounded;
         
     },
     
@@ -229,6 +271,11 @@ Tasks = {
         XObject.extend(args,setv);
         args.id = _this.curTask.id;
         
+        
+        //print(JSON.stringify(args));
+        //return;
+    
+    
          _this = this;
          // do the request to get the task..
         var r = new XMLHttpRequest({
@@ -238,14 +285,12 @@ Tasks = {
                     return;
                 }
                 
-                  
+                 print( this.responseText)
+                 
                 var res = JSON.parse(this.responseText);
                 
-                //print(JSON.stringify(res,null,4))
+                print(JSON.stringify(res,null,4))
                 //print([ res.success , res.data.length ]);
-                _this.curTask = (res.success && res.data.length) ? (new Task(res.data[0])) : false;
-                print(JSON.stringify(_this.curTask,null,4));
-                _this.fetchRepo();
             }
             
         });