Pman.Lock.js
[Pman.Core] / Pman.Lock.js
1 //<script type="text/javascript">
2 /**
3  * Locking - 
4  * 
5  * usage:
6  * 
7  
8     * new Pman.Lock( {
9           table : 'Product',
10          id : 123,
11          success : function(lock) { ..show dialog etc..... 
12           
13            ... dostuff..
14            ... send _lock=XXX to Roo updated code..
15            
16             lock.unlock() -- we dont care about the result..
17           }
18         }
19     * 
20  * 
21  * 
22  *  call : 
23  * try and lock it..
24  * baseURL + /Core/Lock/lock?on_id=...&on_table=...
25  * - returns id or an array of who has the locks.
26  * 
27  * Force an unlock after a warning..
28  * baseURL + /Core/Lock/lock?on_id=...&on_table=...&force=1
29  * - returns id..
30  * 
31  * Unlock - call when window is closed..
32  * baseURL + /Core/Lock/unlock?on_id=...&on_table=...&force=1
33  * - returns jerr or jok
34  * 
35  */
36 Pman.Lock = function (cfg) {
37         this.cfg = cfg;
38         var _t = this;
39         Pman.Request({
40             url : baseURL + 'Core/Lock.php',
41             params : {
42                 on_table : cfg.table,
43                 on_id : cfg.id
44             },
45             failure : function() {
46                 Roo.MessageBox.alert("Error", "Lock Request failed, please try again");
47             },
48             success : function(data)
49             {
50                 Roo.log(data);
51                 
52                 _t.cfg.success.call(_t,_t);
53                 
54                 
55             }
56         })
57     
58     
59     },
60     unlock : function() {
61         
62     }
63     
64
65 }
66