1 //<script type="text/javascript">
4 Pman.on('beforeload', function()
6 // case 1 : Pman.Tab.Projects.add(this.mainLayout, 'west'); break;
9 if (Pman.hasPerm('Core.Companies', 'E')) {
11 modKey : '030-pman-tab-companies',
12 module : Pman.Tab.Companies,
14 parent : Pman.Tab.Admin,
15 name : "Contact Companies Manager"
21 Pman.Tab.Companies = new Roo.util.Observable({
23 'beforerender' : true // trigger so we can add modules later..
25 colExtra : [], // extra items on columns
29 add : function(parentLayout, region) {
33 parentLayout.getRegion(region).showPanel(this.panel);
38 this.innerLayout = new Ext.BorderLayout(
39 parentLayout.getEl().createChild({tag:'div'}),
58 this.tab = parentLayout.add(region, new Ext.NestedLayoutPanel(
59 this.innerLayout, {title: "Companies", background: true, controller : this}));
61 this.tab.on('activate', function() {
62 _this.delayedCreate();
63 _this.paging.onClick('refresh');
66 delayedCreate : function ()
72 this.innerLayout.beginUpdate();
75 var frm = this.innerLayout.getEl().createChild({tag:'div'});
76 //this.grid = new Ext.grid.EditorGrid(frm, {
77 this.grid = new Ext.grid.Grid(frm, {
79 ds: new Ext.data.Store({
81 proxy: new Ext.data.HttpProxy({
82 url: baseURL + '/Roo/Companies.html',
85 reader: Pman.Readers.Companies,
90 Pman.Tab.Office.paging.onClick('refresh');
92 loadexception : Pman.loadException
96 cm: new Ext.grid.ColumnModel(
101 dataIndex : 'comptype',
104 renderer : function (v,x ,r) {
105 return Pman.Dialog.Companies.comptypeListToString(r.data.isOwner ? 'OWNER' : v);
117 id : 'companies-name',
122 renderer : function(v,x,r) {
123 return String.format(r.data.isOwner ? '<B>{0}</B>' : '{0}',v);
140 renderer : function (v) {
141 return (v.length && v.indexOf('@') > 0 ) ?
142 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
146 id : 'companies-address',
148 dataIndex : 'address',
152 id : 'companies-remarks',
154 dataIndex : 'remarks',
159 autoExpandColumn: 'companies-address' , // fixme!!!!
167 cellclick : function(g, ri, ci ,e) {
169 Pman.Tab.Office.paging.onClick('refresh');
172 rowdblclick : function(g, ri, e) {
173 var s = g.getDataSource().getAt(ri).data;
175 _dialog.show(s, refreshPager);
180 this.panel = this.innerLayout.add('center', new Ext.GridPanel(this.grid ,
181 { fitToframe: true,fitContainer: true, controller : this })
184 var gridFoot = this.grid.getView().getFooterPanel(true);
185 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
188 displayMsg: "Displaying Companies {0} - {1} of {2}",
189 emptyMsg: "No Companies found"
191 var grid = this.grid;
193 var gridHead = this.grid.getView().getHeaderPanel(true);
194 var tb = new Ext.Toolbar(gridHead);
196 var refreshPager = function() {
197 _this.paging.onClick('refresh');
199 var _dialog = Pman.Dialog.Companies;
203 cls: 'x-btn-text-icon',
204 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
205 hidden : !Pman.hasPerm('Core.Companies', 'A'),
206 handler : function(){
207 _dialog.show( { id : 0 }, refreshPager );
212 cls: 'x-btn-text-icon',
213 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
214 hidden : !Pman.hasPerm('Core.Companies', 'E'),
215 handler : function(){
216 var s = grid.getSelectionModel().getSelections();
217 if (!s.length || (s.length > 1)) {
218 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
222 _dialog.show(s[0].data, refreshPager);
227 cls: 'x-btn-text-icon',
228 hidden : !Pman.hasPerm('Core.Companies', 'D'),
229 icon: rootURL + '/Pman/templates/images/trash.gif',
231 handler : function(){
232 Pman.genericDelete(_this, 'Companies');
237 Pman.Tab.Office.add(this.innerLayout, 'south');
239 // add stuff to toolbar?
240 this.innerLayout.endUpdate();
245 show: function (parentLayout, region)
247 this.add(parentLayout, region);
248 this.grid.getDataSource().load({
256 getSelectedId : function()
258 var s = this.grid.getSelectionModel().getSelections();