1 //<script type="text/javascript">
7 add : function(parentLayout, region) {
9 if (!Pman.hasPerm('Core.Office','S')) {
15 parentLayout.getRegion(region).showPanel(this.panel);
20 this.innerLayout = new Ext.BorderLayout(
21 parentLayout.getEl().createChild({tag:'div'}),
32 this.tab = parentLayout.add(region, new Ext.NestedLayoutPanel(
33 this.innerLayout, {title: "Offices / Departments / Sub-Companies" }));
36 this.innerLayout.beginUpdate();
37 var _dialog = Pman.Dialog.Office;
38 var refreshPager = function() {
39 _this.paging.onClick('refresh');
42 //this.grid = new Ext.grid.EditorGrid(frm, {
43 this.grid = new Ext.grid.Grid(this.innerLayout.getEl().createChild({tag:'div'}), {
45 ds: new Ext.data.Store({
47 proxy: new Ext.data.HttpProxy({
48 url: baseURL + '/Roo/Office.html',
51 reader: Pman.Readers.Office,
54 beforeload: function(t, o) {
55 //console.log(o.params);
56 o.params.company_id = Pman.Tab.Companies.getSelectedId();
57 if (!o.params.company_id) {
63 loadexception : Pman.loadException
67 cm: new Ext.grid.ColumnModel(
70 header : "Name / Department / Sub Comp.",
75 'id' : 'Office-phone',
77 'dataIndex' : 'phone',
87 'id' : 'Office-email',
89 'dataIndex' : 'email',
92 renderer : function (v) {
93 return (v.length && v.indexOf('@') > 0 ) ?
94 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
98 'id' : 'Office-address',
100 'dataIndex' : 'address',
105 autoExpandColumn: 'Office-address' , // fixme!!!!
111 rowdblclick : function(g, ri, e) {
112 var s = g.getDataSource().getAt(ri).data
113 s.company_name = Pman.Tab.Companies.grid.getSelectionModel().getSelected().data.name;
114 _dialog.show(s, refreshPager);
119 this.panel = this.innerLayout.add('center', new Ext.GridPanel(this.grid ,
120 { fitToframe: true,fitContainer: true })
123 var gridFoot = this.grid.getView().getFooterPanel(true);
124 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
127 displayMsg: "Displaying Offices {0} - {1} of {2}",
128 emptyMsg: "No Offices found"
130 var grid = this.grid;
132 var gridHead = this.grid.getView().getHeaderPanel(true);
133 var tb = new Ext.Toolbar(gridHead);
134 var _this = Pman.Tab.Office;
141 cls: 'x-btn-text-icon',
142 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
143 hidden : !Pman.hasPerm('Core.Offices', 'A'),
144 handler : function(){
145 if (!Pman.Tab.Companies.grid.getSelectionModel().getSelections().length) {
146 Ext.MessageBox.alert("Select a company to add a office to");
149 var cdata = Pman.Tab.Companies.grid.getSelectionModel().getSelected().data;
152 company_name : cdata.name,
153 company_id : cdata.id,
154 address : cdata.address,
163 cls: 'x-btn-text-icon',
164 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
165 hidden : !Pman.hasPerm('Core.Offices', 'E'),
166 handler : function(){
167 var s = grid.getSelectionModel().getSelections();
168 if (!s.length || (s.length > 1)) {
169 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
172 // we should have company_id - just need name..
173 s[0].data.company_name = Pman.Tab.Companies.grid.getSelectionModel().getSelected().data.name;
174 _dialog.show(s[0].data, refreshPager);
180 cls: 'x-btn-text-icon',
181 icon: rootURL + '/Pman/templates/images/trash.gif',
182 hidden : !Pman.hasPerm('Core.Offices', 'D'),
183 handler : function(){
184 Pman.genericDelete(_this, 'Office');
188 this.tab.on('activate', function() {
189 //_this.paging.onClick('refresh');
193 // add stuff to toolbar?
194 this.innerLayout.endUpdate();
199 show: function (parentLayout, region)
201 this.add(parentLayout, region);
202 this.grid.getDataSource().load({