1 //<script type="text/javascript">
4 Pman.on('beforeload', function()
6 // case 1 : Pman.Tab.Projects.add(this.mainLayout, 'west'); break;
11 modKey : '030-pman-tab-companies',
12 module : Pman.Tab.Companies,
14 parent : Pman.Tab.Admin,
15 name : "Contact Companies Manager",
16 permname : 'Admin.Companies'
22 Pman.Tab.Companies = new Roo.util.Observable({
24 'beforerender' : true // trigger so we can add modules later..
26 colExtra : [], // extra items on columns
30 add : function(parentLayout, region) {
34 parentLayout.getRegion(region).showPanel(this.panel);
39 this.innerLayout = new Ext.BorderLayout(
40 parentLayout.getEl().createChild({tag:'div'}),
49 hidden : !Pman.hasPerm('Core.Office','S'),
60 this.tab = parentLayout.add(region, new Ext.NestedLayoutPanel(
61 this.innerLayout, {title: "Companies", background: true, controller : this}));
63 this.tab.on('activate', function() {
64 _this.delayedCreate();
65 _this.paging.onClick('refresh');
68 delayedCreate : function ()
74 this.innerLayout.beginUpdate();
77 var frm = this.innerLayout.getEl().createChild({tag:'div'});
78 //this.grid = new Ext.grid.EditorGrid(frm, {
79 this.grid = new Ext.grid.Grid(frm, {
81 ds: new Ext.data.Store({
83 proxy: new Ext.data.HttpProxy({
84 url: baseURL + '/Roo/Companies.html',
87 reader: Pman.Readers.Companies,
92 if (Pman.Tab.Office.paging) {
93 Pman.Tab.Office.paging.onClick('refresh');
96 loadexception : Pman.loadException
100 cm: new Ext.grid.ColumnModel(
105 dataIndex : 'comptype',
108 renderer : function (v,x ,r) {
109 return Pman.Dialog.Companies.comptypeListToString(r.data.isOwner ? 'OWNER' : v);
121 id : 'companies-name',
126 renderer : function(v,x,r) {
127 return String.format(r.data.isOwner ? '<B>{0}</B>' : '{0}',v);
144 renderer : function (v) {
145 return (v.length && v.indexOf('@') > 0 ) ?
146 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
150 id : 'companies-address',
152 dataIndex : 'address',
156 id : 'companies-remarks',
158 dataIndex : 'remarks',
163 autoExpandColumn: 'companies-address' , // fixme!!!!
171 cellclick : function(g, ri, ci ,e) {
173 if (Pman.Tab.Office.paging) {
174 Pman.Tab.Office.paging.onClick('refresh');
178 rowdblclick : function(g, ri, e) {
179 var s = g.getDataSource().getAt(ri).data;
181 _dialog.show(s, refreshPager);
186 this.panel = this.innerLayout.add('center', new Ext.GridPanel(this.grid ,
187 { fitToframe: true,fitContainer: true, controller : this })
190 var gridFoot = this.grid.getView().getFooterPanel(true);
191 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
194 displayMsg: "Displaying Companies {0} - {1} of {2}",
195 emptyMsg: "No Companies found"
197 var grid = this.grid;
199 var gridHead = this.grid.getView().getHeaderPanel(true);
200 var tb = new Ext.Toolbar(gridHead);
202 var refreshPager = function() {
203 _this.paging.onClick('refresh');
205 var _dialog = Pman.Dialog.Companies;
209 cls: 'x-btn-text-icon',
210 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
211 hidden : !Pman.hasPerm('Core.Companies', 'A'),
212 handler : function(){
213 _dialog.show( { id : 0 }, refreshPager );
218 cls: 'x-btn-text-icon',
219 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
220 hidden : !Pman.hasPerm('Core.Companies', 'E'),
221 handler : function(){
222 var s = grid.getSelectionModel().getSelections();
223 if (!s.length || (s.length > 1)) {
224 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
228 _dialog.show(s[0].data, refreshPager);
233 cls: 'x-btn-text-icon',
234 hidden : !Pman.hasPerm('Core.Companies', 'D'),
235 icon: rootURL + '/Pman/templates/images/trash.gif',
237 handler : function(){
238 Pman.genericDelete(_this, 'Companies');
242 if (Pman.hasPerm('Core.Office','S')) {
243 Pman.Tab.Office.add(this.innerLayout, 'south');
247 // add stuff to toolbar?
248 this.innerLayout.endUpdate();
253 show: function (parentLayout, region)
255 this.add(parentLayout, region);
256 this.grid.getDataSource().load({
264 getSelectedId : function()
266 var s = this.grid.getSelectionModel().getSelections();