Pman.Lock.js
[Pman.Core] / Pman.Lock.js
index 823d687..7229987 100644 (file)
@@ -5,7 +5,7 @@
  * usage:
  * 
  
-    * new Pman.Lock( {
+     new Pman.Lock( {
           table : 'Product',
          id : 123,
          success : function(lock) { ..show dialog etc..... 
  * 
  */
 Pman.Lock = function (cfg) {
-        this.cfg = cfg;
-        var _t = this;
+    this.cfg = cfg;
+    this.attemptLock();
+}
+
+Roo.apply(Pman.Lock.prototype, {
+    
+    attemptLock : function()
+    {
+        var _t = this
         Pman.Request({
-            url : baseURL + 'Core/Lock.php',
+            url : baseURL + 'Core/Lock/lock',
             params : {
                 on_table : cfg.table,
                 on_id : cfg.id
@@ -49,18 +56,54 @@ Pman.Lock = function (cfg) {
             {
                 Roo.log(data);
                 
-                _t.cfg.success.call(_t,_t);
+                if (typeof(data) == 'object') {
+                    _t.confirmBreak(data);
+                }
+                
+                _t.cfg.success(_t); //dont care about scope..
                 
                 
             }
         })
+    },
+    confirmBreak : function (ar)
+    {
+        
+        var msg = '';
+        Roo.each(ar, function(p) {
+            
+           }
+        
+        
+        
+    }
     
     
-    },
     unlock : function() {
-        
+        Pman.Request({
+            url : baseURL + 'Core/Lock/unlock',
+            params : {
+                id : this.lock_id,
+                on_id : cfg.id
+            },
+            failure : function() {
+                Roo.MessageBox.alert("Error", "Lock Request failed, please try again");
+            },
+            success : function(data)
+            {
+                Roo.log(data);
+                
+                if (typeof(data) == 'object') {
+                    _t.confirmBreak(data);
+                }
+                
+                _t.cfg.success(_t); //dont care about scope..
+                
+                
+            }
+        })
     }
     
 
-}
+});
  
\ No newline at end of file