Pman.Tab.AdminCompanies.bjs
[Pman.Admin] / Pman.Tab.AdminCompanies.js
index 89d24e8..280dffa 100644 (file)
@@ -2,37 +2,22 @@
 
 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
 
-
-
-// register the module first
-Pman.on('beforeload', function()
-{
-    Pman.register({
-        modKey : '001-Pman.Tab.AdminCompanies',
-        module : Pman.Tab.AdminCompanies,
-        region : 'center',
-        parent : false,
-        name : "unnamed module",
-        disabled : false, 
-        permname: '' 
-    });
-});
-
-Pman.Tab.AdminCompanies = new Roo.util.Observable({
-
-    panel : false,
-    disabled : false,
-    parentLayout:  false,
-
-    add : function(parentLayout, region)
+Pman.Tab.AdminCompanies = new Roo.XComponent({
+    part     :  ["Admin","Companies"],
+    order    : '030-Pman.Tab.AdminCompanies',
+    region   : 'center',
+    parent   : 'Pman.Tab.Admin',
+    name     : "Pman.Tab.AdminCompanies",
+    disabled : false, 
+    permname : 'Admin.Companies', 
+    _tree : function()
     {
-
         var _this = this;
-        this.parentLayout = parentLayout;
-
-        this.panel = parentLayout.addxtype({
+        var MODULE = this;
+        return {
             xtype: 'NestedLayoutPanel',
             xns: Roo,
+            region : 'center',
             title : "Companies",
             layout : {
                 xtype: 'BorderLayout',
@@ -41,12 +26,6 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                     {
                         xtype: 'GridPanel',
                         xns: Roo,
-                        title : "Companies",
-                        fitToframe : true,
-                        fitContainer : true,
-                        tableName : 'Companies',
-                        background : true,
-                        region : 'center',
                         listeners : {
                             activate : function() {
                                 _this.panel = this;
@@ -55,6 +34,12 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                 }
                             }
                         },
+                        background : true,
+                        fitContainer : true,
+                        fitToframe : true,
+                        region : 'center',
+                        tableName : 'Companies',
+                        title : "Companies",
                         grid : {
                             xtype: 'Grid',
                             xns: Roo.grid,
@@ -62,7 +47,7 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                 render : function() 
                                 {
                                     _this.grid = this; 
-                                    //_this.dialog = Pman.Dialog.FILL_IN
+                                     _this.dialog = Pman.Dialog.Companies;
                                     if (_this.panel.active) {
                                        this.footer.onClick('first');
                                     }
@@ -70,9 +55,15 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                 rowdblclick : function (_self, rowIndex, e)
                                 {
                                     if (!_this.dialog) return;
-                                    _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
+                                    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
                                         _this.grid.footer.onClick('first');
                                     }); 
+                                    
+                                    
+                                },
+                                rowclick : function (_self, rowIndex, e)
+                                {
+                                  try { Pman.Tab.AdminOffice.grid.footer.onClick('refresh'); } catch(e) {}
                                 }
                             },
                             autoExpandColumn : 'name',
@@ -84,12 +75,19 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                     load : function (_self, records, options)
                                     {
                                        try {
-                                            Pman.Tab.Office.grid.footer.onClick('refresh');
+                                            Pman.Tab.AdminOffice.grid.footer.onClick('refresh');
                                         } catch (e) {}
+                                    },
+                                    beforeload : function (_self, o)
+                                    {
+                                       o.params = o.params || {};
+                                       try {
+                                           o.params['query[name]'] = _this.searchBox.getValue();
+                                       } catch(e) { return false; }
                                     }
                                 },
                                 remoteSort : true,
-                                sortInfo : { field : 'code', direction: 'ASC' },
+                                sortInfo : { field : 'name', direction: 'ASC' },
                                 proxy : {
                                     xtype: 'HttpProxy',
                                     xns: Roo.data,
@@ -379,8 +377,8 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                 xns: Roo,
                                 pageSize : 25,
                                 displayInfo : true,
-                                displayMsg : 'Displaying Companies{0} - {1} of {2}',
-                                emptyMsg : 'No Companies found'
+                                displayMsg : "Displaying Companies{0} - {1} of {2}",
+                                emptyMsg : "No Companies found"
                             },
                             toolbar : {
                                 xtype: 'Toolbar',
@@ -392,6 +390,16 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                         listeners : {
                                             show : function (_self)
                                             {
+                                            
+                                            },
+                                            specialkey : function (_self, e)
+                                            {
+                                             if (e.getKey() == 13) {
+                                                 _this.grid.footer.onClick( 'first' );
+                                              }
+                                            },
+                                            render : function (_self)
+                                            {
                                             _this.searchBox = _self;
                                             }
                                         }
@@ -428,9 +436,6 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                     {
                                         xtype: 'Button',
                                         xns: Roo.Toolbar,
-                                        text : "Add",
-                                        cls : 'x-btn-text-icon',
-                                        icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
                                         listeners : {
                                             click : function()
                                             {
@@ -439,14 +444,14 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                                     _this.grid.footer.onClick('first');
                                                }); 
                                             }
-                                        }
+                                        },
+                                        cls : 'x-btn-text-icon',
+                                        text : "Add",
+                                        icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
                                     },
                                     {
                                         xtype: 'Button',
                                         xns: Roo.Toolbar,
-                                        text : "Edit",
-                                        cls : 'x-btn-text-icon',
-                                        icon : Roo.rootURL + 'images/default/tree/leaf.gif',
                                         listeners : {
                                             click : function()
                                             {
@@ -461,7 +466,10 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                                 }); 
                                                 
                                             }
-                                        }
+                                        },
+                                        cls : 'x-btn-text-icon',
+                                        text : "Edit",
+                                        icon : Roo.rootURL + 'images/default/tree/leaf.gif'
                                     },
                                     {
                                         xtype: 'Button',
@@ -487,7 +495,8 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                     sortable : true,
                                     width : 90,
                                     renderer : function (v,x ,r) {
-                                        return Pman.Dialog.Companies.comptypeListToString(r.data.isOwner ? 'OWNER' : v);
+                                        //return Pman.Dialog.Companies.comptypeListToString(r.data.isOwner ? 'OWNER' : v);
+                                        return v;
                                     }
                                 },
                                 {
@@ -495,6 +504,7 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                     xns: Roo.grid,
                                     dataIndex : 'code',
                                     header : 'Ref#',
+                                    sortable : true,
                                     width : 50,
                                     renderer : function(v) { return String.format('{0}', v); }
                                 },
@@ -503,9 +513,10 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                     xns: Roo.grid,
                                     dataIndex : 'name',
                                     header : 'Name',
+                                    sortable : true,
                                     width : 200,
                                     renderer : function(v,x,r) {
-                                        return String.format(r.data.isOwner ? '<B>{0}</B>' : '{0}',v);    
+                                        return String.format(r.data.comptype == 'OWNER' ? '<B>{0}</B>' : '{0}',v);    
                                     }
                                 },
                                 {
@@ -529,6 +540,7 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                     xns: Roo.grid,
                                     dataIndex : 'email',
                                     header : 'Email',
+                                    sortable : true,
                                     width : 100,
                                     renderer : function (v) {
                                             return (v.length && v.indexOf('@') > 0 ) ? 
@@ -539,9 +551,10 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                                 {
                                     xtype: 'ColumnModel',
                                     xns: Roo.grid,
+                                    dataIndex : 'address',
                                     header : 'Address',
+                                    sortable : true,
                                     width : 200,
-                                    dataIndex : 'address',
                                     renderer : function(v) { return String.format('{0}', v); }
                                 },
                                 {
@@ -562,11 +575,12 @@ Pman.Tab.AdminCompanies = new Roo.util.Observable({
                 },
                 south : {
                     xtype: 'LayoutRegion',
-                    xns: Roo
+                    xns: Roo,
+                    height : 150,
+                    split : true,
+                    titlebar : true
                 }
             }
-        });
-        this.layout = this.panel.layout;
-
+        };
     }
 });