1 //<script type="text/javascript">
7 add : function(parentLayout, region) {
11 parentLayout.getRegion(region).showPanel(this.panel);
16 this.innerLayout = new Ext.BorderLayout(
17 parentLayout.getEl().createChild({tag:'div'}),
28 this.tab = parentLayout.add(region, new Ext.NestedLayoutPanel(
29 this.innerLayout, {title: "Offices / Departments / Sub-Companies" }));
32 this.innerLayout.beginUpdate();
33 var _dialog = Pman.Dialog.Office;
34 var refreshPager = function() {
35 _this.paging.onClick('refresh');
38 //this.grid = new Ext.grid.EditorGrid(frm, {
39 this.grid = new Ext.grid.Grid(this.innerLayout.getEl().createChild({tag:'div'}), {
41 ds: new Ext.data.Store({
43 proxy: new Ext.data.HttpProxy({
44 url: baseURL + '/Roo/Office.html',
47 reader: Pman.Readers.Office,
50 beforeload: function(t, o) {
51 //console.log(o.params);
52 o.params.company_id = Pman.Tab.Companies.getSelectedId();
53 if (!o.params.company_id) {
59 loadexception : Pman.loadException
63 cm: new Ext.grid.ColumnModel(
66 header : "Name / Department / Sub Comp.",
71 'id' : 'Office-phone',
73 'dataIndex' : 'phone',
83 'id' : 'Office-email',
85 'dataIndex' : 'email',
88 renderer : function (v) {
89 return (v.length && v.indexOf('@') > 0 ) ?
90 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
94 'id' : 'Office-address',
96 'dataIndex' : 'address',
101 autoExpandColumn: 'Office-address' , // fixme!!!!
107 rowdblclick : function(g, ri, e) {
108 var s = g.getDataSource().getAt(ri).data
109 s.company_name = Pman.Tab.Companies.grid.getSelectionModel().getSelected().data.name;
110 _dialog.show(s, refreshPager);
115 this.panel = this.innerLayout.add('center', new Ext.GridPanel(this.grid ,
116 { fitToframe: true,fitContainer: true })
119 var gridFoot = this.grid.getView().getFooterPanel(true);
120 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
123 displayMsg: "Displaying Offices {0} - {1} of {2}",
124 emptyMsg: "No Offices found"
126 var grid = this.grid;
128 var gridHead = this.grid.getView().getHeaderPanel(true);
129 var tb = new Ext.Toolbar(gridHead);
130 var _this = Pman.Tab.Office;
137 cls: 'x-btn-text-icon',
138 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
139 hidden : !Pman.hasPerm('Core.Offices', 'A'),
140 handler : function(){
141 if (!Pman.Tab.Companies.grid.getSelectionModel().getSelections().length) {
142 Ext.MessageBox.alert("Select a company to add a office to");
145 var cdata = Pman.Tab.Companies.grid.getSelectionModel().getSelected().data;
148 company_name : cdata.name,
149 company_id : cdata.id,
150 address : cdata.address,
159 cls: 'x-btn-text-icon',
160 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
161 hidden : !Pman.hasPerm('Core.Offices', 'E'),
162 handler : function(){
163 var s = grid.getSelectionModel().getSelections();
164 if (!s.length || (s.length > 1)) {
165 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
168 // we should have company_id - just need name..
169 s[0].data.company_name = Pman.Tab.Companies.grid.getSelectionModel().getSelected().data.name;
170 _dialog.show(s[0].data, refreshPager);
176 cls: 'x-btn-text-icon',
177 icon: rootURL + '/Pman/templates/images/trash.gif',
178 hidden : !Pman.hasPerm('Core.Offices', 'D'),
179 handler : function(){
180 Pman.genericDelete(_this, 'Office');
184 this.tab.on('activate', function() {
185 //_this.paging.onClick('refresh');
189 // add stuff to toolbar?
190 this.innerLayout.endUpdate();
195 show: function (parentLayout, region)
197 this.add(parentLayout, region);
198 this.grid.getDataSource().load({