fix #8131 - chinese translations
[Pman.Core] / Pman.Tab.PersonList.js
index b6d2a27..8ee3fb1 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,12 +139,12 @@ Pman.Tab.PersonList.prototype = {
         }
         this.parentLayout = parentLayout;
         
-        this.layout = new Ext.BorderLayout(
+        this.layout = new Roo.BorderLayout(
             parentLayout.getEl().createChild({tag:'div'}),
             {
                
                 center: {
-                    autoScroll:true,
+                    autoScroll:false,
                     hideTabs: true
                 }
             }
@@ -148,8 +152,13 @@ Pman.Tab.PersonList.prototype = {
 
 
 
-        this.tab = parentLayout.add(region,  new Ext.NestedLayoutPanel(
-            this.layout, {title: this.title, background: true, controller : this}));
+        this.tab = parentLayout.add(region,
+            new Roo.NestedLayoutPanel(
+                this.layout, {
+                    title: this.title,
+                    background: true,
+                    controller : this
+        }));
 
         this.tab.on('activate', function() {
             _this.delayedCreate();
@@ -170,19 +179,19 @@ 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({
-                        url: baseURL + '/Roo/Person.html',
+                    proxy: new Roo.data.HttpProxy({
+                        url: baseURL + '/Roo/core_person',
                         method: 'GET'
                     }),
-                    reader: Pman.Readers.Person,
+                    reader: new Roo.data.JsonReader({}, []),
                     remoteSort: true,
                     listeners : {
                         
@@ -202,7 +211,7 @@ Pman.Tab.PersonList.prototype = {
                             // only used to change active status.
                             
                             new Pman.Request({
-                                url : baseURL + '/Roo/Person.php',
+                                url : baseURL + '/Roo/core_person',
                                 method :'POST',
                                 params : {
                                     id : record.data.id,
@@ -229,10 +238,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,
@@ -247,18 +256,25 @@ Pman.Tab.PersonList.prototype = {
                         
                     },
                     cellclick : function (_self, rowIndex, columnIndex, e)
-                    {
+                    {   
                         var di = this.colModel.getDataIndex(columnIndex);
                         if (di != 'active') {
                             return;
                         }
-                         
+                        
                         var rec = _this.grid.ds.getAt(rowIndex);
                         
                         rec.set('active', rec.data.active ? 0 : 1);
                         rec.commit();
-                         
                         
+                        // only hide if viewing active members... 
+                        if (!_this.showInActive) {
+                            var el = Roo.select('.x-grid-row-selected').item(3);
+                            el.addClass('x-grid-row-fadeout');
+                            el.on('transitionend',function(){
+                                _this.grid.ds.remove(rec);
+                            },this,{single:true});
+                        }
                         
                     }
                     
@@ -266,9 +282,10 @@ 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, 
+                fitContainer: true,
+                //background : false,
                 id: this.id, 
                 title: this.title || "Staff", 
                 controller : this 
@@ -286,7 +303,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 +312,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 +350,7 @@ Pman.Tab.PersonList.prototype = {
         //}
         
      
-        this.searchBox = new Ext.form.TextField({
+        this.searchBox = new Roo.form.TextField({
             name: 'search',
             width:135,
             listeners : {
@@ -355,7 +372,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 +381,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 +393,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 +413,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,8 +426,8 @@ Pman.Tab.PersonList.prototype = {
                     grid.getView().mainWrap.mask("Sending");
 
                     
-                    Ext.Ajax.request({
-                        url: baseURL + '/Roo/Person.html',
+                    Roo.Ajax.request({
+                        url: baseURL + '/Roo/core_person',
                         method: 'GET',
                         params: {
                             _toggleActive : r.join(',')
@@ -419,7 +436,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 +444,7 @@ Pman.Tab.PersonList.prototype = {
                         },
                         failure: function(act) {
                             grid.getView().mainWrap.unmask();
-                            Ext.MessageBox.alert("Error", "Error Sending");
+                            Roo.MessageBox.alert("Error", "Error Sending");
                         }
                         
                     });
@@ -441,7 +458,41 @@ Pman.Tab.PersonList.prototype = {
                 hidden : !Pman.hasPerm(_this.permName, 'D'),    
                 icon: rootURL + '/Pman/templates/images/trash.gif',
                 handler : function(){
-                    Pman.genericDelete(_this, 'Person'); 
+                    //Pman.genericDelete(_this, 'Person'); 
+                    
+                    var rec = _this.grid.ds.getAt(_this.grid.selModel.last);
+                    
+                    var rec_id = rec.id;
+                    
+                    if (rec_id * 1 < 1) {
+                        Roo.MessageBox.alert("Error", "Select row to delete");
+                        return;
+                    }
+
+                    Roo.MessageBox.confirm(
+                        "Confirm", 
+                        "Confirm Deletion of selected row (some rows can not be deleted if they are referenced elsewhere", 
+                        function(res) {
+                            if(res != 'yes') {
+                                return;
+                            }
+                            new Pman.Request({
+                                method : 'POST',
+                                url : baseURL + '/Roo/core_person',
+                                params : {
+                                    _delete  : rec_id
+                                },
+                                success : function() {
+                                    _this.paging.onClick('refresh');
+                                    //_this.grid.footer.onClick('refresh');
+                                }
+                            });
+                        }
+                    );
+
+
+                    
+
                 }
             } ,
 
@@ -476,10 +527,11 @@ Pman.Tab.PersonList.prototype = {
                     refreshPager();
                 }
             },
-            '->',
+            '-',
              {
                
-               
+                xtype : 'Button',
+                xns : Roo.Toolbar,
                
                 text: "Switch to Selected User",
                 hidden : _this.permName != 'Core.Staff' || !Pman.hasPerm('Core.Staff', 'E'),
@@ -487,19 +539,23 @@ Pman.Tab.PersonList.prototype = {
                     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 {
+                            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);
                             }
                         });
                         
@@ -509,7 +565,26 @@ Pman.Tab.PersonList.prototype = {
             
                      
             },
+            '->',
+            
+              {
+               
+                xtype : 'Button',
+                xns : Roo.Toolbar,
+               
+                text: "Bulk Change Passwords",
+                hidden : _this.permName != 'Core.Staff' || !Pman.hasPerm('Core.Staff', 'E'),
+                listeners : {
+                    click : function () {
+                        Pman.Dialog.AdminBulkPassword.show({}, function() { 
+                          refreshPager();
+                        });
+                        
+                    }
+                }
             
+                     
+            }
 
         );
         
@@ -557,13 +632,37 @@ 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,
+            renderer : function(v,p,r) { 
+                if(r.data.active != 1){
+                    return String.format('<div style="text-decoration:line-through">{0}</div>', v); 
+                }
+                return String.format('{0}', v); 
+            }
+          //  width : 150  
+        }, cfg);
+    },
+    
+    c_group_membership : function(cfg) {
+        cfg = cfg || {};
+        return Roo.apply({
+         //   id : (this.id + '-name').toLowerCase(),
+            header : "Group Membership",
+            dataIndex : 'member_of',
+            sortable : false,
+            renderer : function(v,p,r) {
+                if(r.data.active != 1){
+                    return String.format('<div style="text-decoration:line-through">{0}</div>', v).split("\n").join("<br/>"); 
+                }
+                return String.format('{0}', v).split("\n").join("<br/>"); 
+            },
             width : 150  
         }, cfg);
     },
+    
      c_company_id_comptype : function(cfg) {
         cfg = cfg || {};
         return Roo.apply({
@@ -657,7 +756,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 + '"/>';
                 
                 
             }