DataObjects/Core_watch.php
[Pman.Core] / Pman.Tab.PersonList.js
index 31c5510..264b141 100644 (file)
@@ -3,6 +3,8 @@
 /**
  * 
  * generic person list - used by perms. and staff lists.
+ *
+ * -- this is probably depreciated now..
  * 
  */
 
@@ -10,7 +12,7 @@
 
 Pman.Tab.PersonList = function(config)
 {
-    Ext.apply(this, config);
+    Roo.apply(this, config);
 }
 
 Pman.Tab.PersonList.prototype = {
@@ -31,6 +33,7 @@ Pman.Tab.PersonList.prototype = {
         // teams!?!
         alert('person list not configured');
         return false;
+        /*
         var tms = _this.getLeftSelections();
         
         if (tms.length) {
@@ -40,6 +43,7 @@ Pman.Tab.PersonList.prototype = {
         o.params['query[type]'] = this.type; // group type..
         o.params['query[person_internal_only_all]'] = 1;
         o.params['query[person_inactive]'] = this.showInActive ? 0  : 1;
+        */
         
     },
     
@@ -135,7 +139,7 @@ Pman.Tab.PersonList.prototype = {
         }
         this.parentLayout = parentLayout;
         
-        this.layout = new Ext.BorderLayout(
+        this.layout = new Roo.BorderLayout(
             parentLayout.getEl().createChild({tag:'div'}),
             {
                
@@ -148,7 +152,7 @@ Pman.Tab.PersonList.prototype = {
 
 
 
-        this.tab = parentLayout.add(region,  new Ext.NestedLayoutPanel(
+        this.tab = parentLayout.add(region,  new Roo.NestedLayoutPanel(
             this.layout, {title: this.title, background: true, controller : this}));
 
         this.tab.on('activate', function() {
@@ -170,15 +174,15 @@ Pman.Tab.PersonList.prototype = {
         this.layout.beginUpdate();
         
         var frm = this.layout.getRegion('center').getEl().createChild({tag:'div'});
-        //this.grid = new Ext.grid.EditorGrid(frm,  {
-        this.grid = new Ext.grid.Grid(frm,  {
+        //this.grid = new Roo.grid.EditorGrid(frm,  {
+        this.grid = new Roo.grid.Grid(frm,  {
                 ddGroup: 'groupDD',
                 //enableDrag: true,
                 enableDrag: true,
                 id: this.id + '-grid',
-                ds:   new Ext.data.Store({
+                ds:   new Roo.data.Store({
                     // load using HTTP
-                    proxy: new Ext.data.HttpProxy({
+                    proxy: new Roo.data.HttpProxy({
                         url: baseURL + '/Roo/Person.html',
                         method: 'GET'
                     }),
@@ -229,10 +233,10 @@ Pman.Tab.PersonList.prototype = {
                         field: 'name', direction: 'ASC'
                     }
                 }),
-                cm: new Ext.grid.ColumnModel(
+                cm: new Roo.grid.ColumnModel(
                     this.columns()
                 ),
-                autoExpandColumn: _this.id + '-name' , // fixme!!!!
+                autoExpandColumn:  'name', // fixme!!!!
                 clicksToEdit : 1,
                 
                 loadMask: true,
@@ -266,7 +270,7 @@ Pman.Tab.PersonList.prototype = {
                  
                  
         });
-        this.panel  = this.layout.add('center',  new Ext.GridPanel(this.grid , {
+        this.panel  = this.layout.add('center',  new Roo.GridPanel(this.grid , {
                 fitToframe: true,
                 fitContainer: true, 
                 id: this.id, 
@@ -286,7 +290,7 @@ Pman.Tab.PersonList.prototype = {
 
         
         var gridFoot = this.grid.getView().getFooterPanel(true);
-        this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
+        this.paging = new Roo.PagingToolbar(gridFoot, this.grid.getDataSource(), {
             pageSize: 25,
             displayInfo: true,
             displayMsg: "Displaying " + (this.itemDisplayName || "Staff") + " {0} - {1} of {2}",
@@ -295,7 +299,7 @@ Pman.Tab.PersonList.prototype = {
         var grid = this.grid;
  
     
-        this.toolbar = new Ext.Toolbar(this.grid.getView().getHeaderPanel(true));
+        this.toolbar = new Roo.Toolbar(this.grid.getView().getHeaderPanel(true));
         
         var tb = this.toolbar;
         
@@ -333,7 +337,7 @@ Pman.Tab.PersonList.prototype = {
         //}
         
      
-        this.searchBox = new Ext.form.TextField({
+        this.searchBox = new Roo.form.TextField({
             name: 'search',
             width:135,
             listeners : {
@@ -355,7 +359,7 @@ Pman.Tab.PersonList.prototype = {
             {
                 text: "Add",
                 cls: 'x-btn-text-icon',
-                icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
+                icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
                 hidden :  !dg || (_this.newDefaults() === false) || !Pman.hasPerm(this.permName, 'A'),  
                 handler : function(){
                     dg.show(  _this.newDefaults(), refreshPager );  
@@ -364,7 +368,7 @@ Pman.Tab.PersonList.prototype = {
              { ///... for contacts stuff...
                 text: "Bulk Add",
                 cls: 'x-btn-text-icon',
-                icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
+                icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
                 hidden : !this.bulkAdd() || !Pman.hasPerm(this.permName, 'A'),    
                 handler : function(){
                     
@@ -376,12 +380,12 @@ Pman.Tab.PersonList.prototype = {
             {
                 text: "Edit",
                 cls: 'x-btn-text-icon',
-                icon: Ext.rootURL + 'images/default/tree/leaf.gif',
+                icon: Roo.rootURL + 'images/default/tree/leaf.gif',
                 hidden : !dg || !Pman.hasPerm(this.permName, 'E'),    
                 handler : function(){
                     var s = grid.getSelectionModel().getSelections();
                     if (!s.length || (s.length > 1))  {
-                        Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
+                        Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
                         return;
                     }
                     dg.show( s[0].data,refreshPager);
@@ -396,7 +400,7 @@ Pman.Tab.PersonList.prototype = {
                  
                     var s = grid.getSelectionModel().getSelections();
                     if (!s.length  )  {
-                        Ext.MessageBox.alert("Error",  "Select People Row");
+                        Roo.MessageBox.alert("Error",  "Select People Row");
                         return;
                     }
                     var r = [];
@@ -409,7 +413,7 @@ Pman.Tab.PersonList.prototype = {
                     grid.getView().mainWrap.mask("Sending");
 
                     
-                    Ext.Ajax.request({
+                    Roo.Ajax.request({
                         url: baseURL + '/Roo/Person.html',
                         method: 'GET',
                         params: {
@@ -419,7 +423,7 @@ Pman.Tab.PersonList.prototype = {
                             var res = Pman.processResponse(resp);
                             grid.getView().mainWrap.unmask();
                             if (!res.success) {
-                                Ext.MessageBox.alert("Error", res.errorMsg ? res.errorMsg  : "Error Sending");
+                                Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg  : "Error Sending");
                                 return;
                             }
                             refreshPager();
@@ -427,7 +431,7 @@ Pman.Tab.PersonList.prototype = {
                         },
                         failure: function(act) {
                             grid.getView().mainWrap.unmask();
-                            Ext.MessageBox.alert("Error", "Error Sending");
+                            Roo.MessageBox.alert("Error", "Error Sending");
                         }
                         
                     });
@@ -438,7 +442,7 @@ Pman.Tab.PersonList.prototype = {
             {
                 text: "Delete",
                 cls: 'x-btn-text-icon',
-                hidden : !Pman.hasPerm('Core.Person', 'D'),    
+                hidden : !Pman.hasPerm(_this.permName, 'D'),    
                 icon: rootURL + '/Pman/templates/images/trash.gif',
                 handler : function(){
                     Pman.genericDelete(_this, 'Person'); 
@@ -476,26 +480,44 @@ Pman.Tab.PersonList.prototype = {
                     refreshPager();
                 }
             },
-            '->',
+            '-',
              {
                
-               
+                xtype : 'Button',
+                xns : Roo.Toolbar,
                
                 text: "Switch to Selected User",
-                hidden : !Pman.hasPerm('Core.Staff', 'E'),    
+                hidden : _this.permName != 'Core.Staff' || !Pman.hasPerm('Core.Staff', 'E'),
                 listeners : {
                     click : function () { 
                         var s = grid.getSelectionModel().getSelections();
                         if (s.length != 1)  {
-                            Ext.MessageBox.alert("Error",  "Select a Person");
+                            Roo.MessageBox.alert("Error",  "Select a Person");
                             return;
                         }
-                    
+                        new Pman.Request({
+                            url : baseURL+ '/Login.php',
+                            params  :{
+                                'switch' : s[0].data.id
+                            },
+                            
+                            method : 'GET',
+                            success : function() {
+                                document.location = baseURL + '?ts=' + Math.random();
+                                
+                            }, 
+                            failure : function(d) {
+                                Roo.log(d);
+                                Roo.MessageBox.alert("Error",  d);
+                            }
+                        });
+                        
+                        
                     }
                 }
             
                      
-            },
+            }
             
 
         );
@@ -544,11 +566,11 @@ Pman.Tab.PersonList.prototype = {
     c_name : function(cfg) {
         cfg = cfg || {};
         return Roo.apply({
-            id : this.id + '-name',
+         //   id : (this.id + '-name').toLowerCase(),
             header : "Name",
             dataIndex : 'name',
-            sortable : true,
-            width : 150  
+            sortable : true
+          //  width : 150  
         }, cfg);
     },
      c_company_id_comptype : function(cfg) {
@@ -644,7 +666,7 @@ Pman.Tab.PersonList.prototype = {
                 
                 var state = v> 0 ?  '-checked' : '';
 
-                return '<img class="x-grid-check-icon' + state + '" src="' + Ext.BLANK_IMAGE_URL + '"/>';
+                return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
                 
                 
             }