Pman.Tab.AdminOffice.bjs
[Pman.Admin] / Pman.Tab.AdminOffice.js
index c227083..75d5370 100644 (file)
@@ -1 +1,346 @@
-0
\ No newline at end of file
+//<script type="text/javascript">
+
+// Auto generated file - created by app.Builder.js- do not edit directly (at present!)
+
+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;
+        var MODULE = this;
+        return {
+            xtype: 'GridPanel',
+            xns: Roo,
+            listeners : {
+                activate : function() {
+                    _this.panel = this;
+                    if (_this.grid) {
+                        _this.grid.footer.onClick('first');
+                    }
+                }
+            },
+            background : true,
+            fitContainer : true,
+            fitToframe : true,
+            region : 'south',
+            tableName : 'Office',
+            title : "Offices / Departments / Sub-Companies",
+            grid : {
+                xtype: 'Grid',
+                xns: Roo.grid,
+                listeners : {
+                    render : function() 
+                    {
+                        _this.grid = this; 
+                        _this.dialog =Pman.Dialog.Office;
+                        if (_this.panel.active) {
+                           this.footer.onClick('first');
+                        }
+                    },
+                    rowdblclick : function (_self, rowIndex, e)
+                    {
+                        if (!_this.dialog) return;
+                        _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
+                            _this.grid.footer.onClick('first');
+                        }); 
+                    }
+                },
+                autoExpandColumn : 'name',
+                loadMask : true,
+                dataSource : {
+                    xtype: 'Store',
+                    xns: Roo.data,
+                    listeners : {
+                        beforeload : function (_self, o)
+                        {
+                            try {
+                                var sm = Pman.Tab.AdminCompanies.grid.getSelectionModel();
+                                sm = sm.getSelected();
+                                if (!sm || !sm.data.id) {
+                                    // mask??
+                                    return false;
+                                }
+                                       
+                                o.params.company_id = sm.data.id ;
+                            } catch (e) {
+                                return false;
+                            }
+                            
+                            
+                         }
+                    },
+                    remoteSort : true,
+                    sortInfo : { field : 'name', direction: 'ASC' },
+                    proxy : {
+                        xtype: 'HttpProxy',
+                        xns: Roo.data,
+                        method : 'GET',
+                        url : baseURL + '/Roo/Office.php'
+                    },
+                    reader : {
+                        xtype: 'JsonReader',
+                        xns: Roo.data,
+                        totalProperty : 'total',
+                        root : 'data',
+                        id : 'id',
+                        fields : [
+                            {
+                                'name': 'id',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'company_id',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'name',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'address',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'phone',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'fax',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'email',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'role',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_code',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_name',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_remarks',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_owner_id',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'company_id_address',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_tel',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_fax',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_email',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_id',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'company_id_isOwner',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'company_id_logo_id',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'company_id_background_color',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_comptype',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_url',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_main_office_id',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'company_id_created_by',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'company_id_created_dt',
+                                'type': 'date'
+                            },
+                            {
+                                'name': 'company_id_updated_by',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'company_id_updated_dt',
+                                'type': 'date'
+                            },
+                            {
+                                'name': 'company_id_passwd',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_dispatch_port',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_province',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'company_id_country',
+                                'type': 'string'
+                            }
+                        ]
+                    }
+                },
+                footer : {
+                    xtype: 'PagingToolbar',
+                    xns: Roo,
+                    pageSize : 25,
+                    displayInfo : true,
+                    displayMsg : "Displaying Office{0} - {1} of {2}",
+                    emptyMsg : "No Office found"
+                },
+                toolbar : {
+                    xtype: 'Toolbar',
+                    xns: Roo,
+                    items : [
+                        {
+                            xtype: 'Button',
+                            xns: Roo.Toolbar,
+                            listeners : {
+                                click : function()
+                                {
+                                    if (!_this.dialog) return;
+                                    
+                                    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,
+                            listeners : {
+                                click : function()
+                                {
+                                    var s = _this.grid.getSelectionModel().getSelections();
+                                    if (!s.length || (s.length > 1))  {
+                                        Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
+                                        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',
+                            xns: Roo.Toolbar,
+                            text : "Delete",
+                            cls : 'x-btn-text-icon',
+                            icon : rootURL + '/Pman/templates/images/trash.gif',
+                            listeners : {
+                                click : function()
+                                {
+                                     Pman.genericDelete(_this, 'Office'); 
+                                }
+                            }
+                        }
+                    ]
+                },
+                colModel : [
+                    {
+                        xtype: 'ColumnModel',
+                        xns: Roo.grid,
+                        dataIndex : 'name',
+                        header : 'Name / Department / Sub Comp.',
+                        sortable : true,
+                        width : 200,
+                        renderer : function(v) { return String.format('{0}', v); }
+                    },
+                    {
+                        xtype: 'ColumnModel',
+                        xns: Roo.grid,
+                        dataIndex : 'phone',
+                        header : 'Phone',
+                        width : 100,
+                        renderer : function(v) { return String.format('{0}', v); }
+                    },
+                    {
+                        xtype: 'ColumnModel',
+                        xns: Roo.grid,
+                        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,
+                        renderer : function (v) {
+                            return (v.length && v.indexOf('@') > 0 ) ? 
+                                String.format('<a href="mailto:{0}">{0}</a>',v) : v;
+                                
+                        }
+                    },
+                    {
+                        xtype: 'ColumnModel',
+                        xns: Roo.grid,
+                        dataIndex : 'address',
+                        header : 'Address',
+                        width : 300,
+                        renderer : function(v) { return String.format('{0}', v); }
+                    }
+                ]
+            }
+        };
+    }
+});