Pman.Tab.AdminOffice.bjs
[Pman.Admin] / Pman.Tab.AdminOffice.js
index d9087b5..75d5370 100644 (file)
@@ -2,35 +2,19 @@
 
 // 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.AdminOffice',
-        module : Pman.Tab.AdminOffice,
-        region : 'center',
-        parent : Pman.Tab.AdminCompanies,
-        name : "Pman.Tab.AdminOffice",
-        disabled : false, 
-        permname: '' 
-    });
-});
-
-Pman.Tab.AdminOffice = new Roo.util.Observable({
-
-    panel : false,
-    disabled : false,
-    parentLayout:  false,
-
-    add : function(parentLayout, region)
+Pman.Tab.AdminOffice = new Roo.XComponent({
+    part     :  ["Admin","Office"],
+    order    : '001-Pman.Tab.AdminOffice',
+    region   : 'center',
+    parent   : 'Pman.Tab.AdminCompanies',
+    name     : "Pman.Tab.AdminOffice",
+    disabled : false, 
+    permname : '', 
+    _tree : function()
     {
-
         var _this = this;
-        this.parentLayout = parentLayout;
-
-        this.panel = parentLayout.addxtype({
+        var MODULE = this;
+        return {
             xtype: 'GridPanel',
             xns: Roo,
             listeners : {
@@ -44,19 +28,17 @@ Pman.Tab.AdminOffice = new Roo.util.Observable({
             background : true,
             fitContainer : true,
             fitToframe : true,
-            region : 'center',
+            region : 'south',
             tableName : 'Office',
             title : "Offices / Departments / Sub-Companies",
             grid : {
                 xtype: 'Grid',
                 xns: Roo.grid,
-                autoExpandColumn : 'name',
-                loadMask : true,
                 listeners : {
                     render : function() 
                     {
                         _this.grid = this; 
-                        //_this.dialog = Pman.Dialog.FILL_IN
+                        _this.dialog =Pman.Dialog.Office;
                         if (_this.panel.active) {
                            this.footer.onClick('first');
                         }
@@ -64,11 +46,13 @@ Pman.Tab.AdminOffice = 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');
                         }); 
                     }
                 },
+                autoExpandColumn : 'name',
+                loadMask : true,
                 dataSource : {
                     xtype: 'Store',
                     xns: Roo.data,
@@ -76,7 +60,7 @@ Pman.Tab.AdminOffice = new Roo.util.Observable({
                         beforeload : function (_self, o)
                         {
                             try {
-                                var sm = Pman.Tab.Companies.grid.getSelectionModel();
+                                var sm = Pman.Tab.AdminCompanies.grid.getSelectionModel();
                                 sm = sm.getSelected();
                                 if (!sm || !sm.data.id) {
                                     // mask??
@@ -88,6 +72,7 @@ Pman.Tab.AdminOffice = new Roo.util.Observable({
                                 return false;
                             }
                             
+                            
                          }
                     },
                     remoteSort : true,
@@ -237,8 +222,8 @@ Pman.Tab.AdminOffice = new Roo.util.Observable({
                     xns: Roo,
                     pageSize : 25,
                     displayInfo : true,
-                    displayMsg : 'Displaying Office{0} - {1} of {2}',
-                    emptyMsg : 'No Office found'
+                    displayMsg : "Displaying Office{0} - {1} of {2}",
+                    emptyMsg : "No Office found"
                 },
                 toolbar : {
                     xtype: 'Toolbar',
@@ -247,25 +232,32 @@ Pman.Tab.AdminOffice = 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()
                                 {
                                     if (!_this.dialog) return;
-                                    _this.dialog.show( { id : 0 } , function() {
+                                    
+                                    var cdata = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected().data;
+                                    _dialog.show( { 
+                                        id : 0 ,
+                                        company_name : cdata.name,
+                                        company_id : cdata.id,
+                                        address : cdata.address,
+                                        phone : cdata.tel,
+                                        fax : cdata.fax,
+                                        email  : cdata.email
+                                    } , function() {
                                         _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()
                                 {
@@ -275,12 +267,16 @@ Pman.Tab.AdminOffice = new Roo.util.Observable({
                                         return;
                                     }
                                     if (!_this.dialog) return;
+                                    s[0].data.company_name = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected().data.name;
                                     _this.dialog.show(s[0].data, function() {
                                         _this.grid.footer.onClick('first');
                                     }); 
                                     
                                 }
-                            }
+                            },
+                            cls : 'x-btn-text-icon',
+                            text : "Edit",
+                            icon : Roo.rootURL + 'images/default/tree/leaf.gif'
                         },
                         {
                             xtype: 'Button',
@@ -303,6 +299,7 @@ Pman.Tab.AdminOffice = new Roo.util.Observable({
                         xns: Roo.grid,
                         dataIndex : 'name',
                         header : 'Name / Department / Sub Comp.',
+                        sortable : true,
                         width : 200,
                         renderer : function(v) { return String.format('{0}', v); }
                     },
@@ -317,39 +314,33 @@ Pman.Tab.AdminOffice = new Roo.util.Observable({
                     {
                         xtype: 'ColumnModel',
                         xns: Roo.grid,
-                        header : 'Fax',
-                        width : 200,
                         dataIndex : 'fax',
+                        header : 'Fax',
+                        width : 100,
                         renderer : function(v) { return String.format('{0}', v); }
                     },
                     {
                         xtype: 'ColumnModel',
                         xns: Roo.grid,
+                        dataIndex : 'email',
                         header : 'Email',
                         width : 200,
-                        dataIndex : 'email',
-                        renderer : function(v) { return String.format('{0}', v); }
+                        renderer : function (v) {
+                            return (v.length && v.indexOf('@') > 0 ) ? 
+                                String.format('<a href="mailto:{0}">{0}</a>',v) : v;
+                                
+                        }
                     },
                     {
                         xtype: 'ColumnModel',
                         xns: Roo.grid,
-                        header : 'Address',
-                        width : 200,
                         dataIndex : 'address',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Role',
-                        width : 200,
-                        dataIndex : 'role',
+                        header : 'Address',
+                        width : 300,
                         renderer : function(v) { return String.format('{0}', v); }
                     }
                 ]
             }
-        });
-        this.layout = this.panel.layout;
-
+        };
     }
 });