Pman.Tab.AdminOffice.bjs
[Pman.Admin] / Pman.Tab.AdminOffice.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.AdminOffice = new Roo.XComponent({
6     part     :  ["Admin","Office"],
7     order    : '001-Pman.Tab.AdminOffice',
8     region   : 'center',
9     parent   : 'Pman.Tab.AdminCompanies',
10     name     : "Pman.Tab.AdminOffice",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'GridPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function() {
22                     _this.panel = this;
23                     if (_this.grid) {
24                         _this.grid.footer.onClick('first');
25                     }
26                 }
27             },
28             background : true,
29             fitContainer : true,
30             fitToframe : true,
31             region : 'south',
32             tableName : 'Office',
33             title : "Offices / Departments / Sub-Companies",
34             grid : {
35                 xtype: 'Grid',
36                 xns: Roo.grid,
37                 listeners : {
38                     render : function() 
39                     {
40                         _this.grid = this; 
41                         _this.dialog =Pman.Dialog.Office;
42                         if (_this.panel.active) {
43                            this.footer.onClick('first');
44                         }
45                     },
46                     rowdblclick : function (_self, rowIndex, e)
47                     {
48                         if (!_this.dialog) return;
49                         _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
50                             _this.grid.footer.onClick('first');
51                         }); 
52                     }
53                 },
54                 autoExpandColumn : 'name',
55                 loadMask : true,
56                 dataSource : {
57                     xtype: 'Store',
58                     xns: Roo.data,
59                     listeners : {
60                         beforeload : function (_self, o)
61                         {
62                             try {
63                                 var sm = Pman.Tab.AdminCompanies.grid.getSelectionModel();
64                                 sm = sm.getSelected();
65                                 if (!sm || !sm.data.id) {
66                                     // mask??
67                                     return false;
68                                 }
69                                        
70                                 o.params.company_id = sm.data.id ;
71                             } catch (e) {
72                                 return false;
73                             }
74                             
75                             
76                          }
77                     },
78                     remoteSort : true,
79                     sortInfo : { field : 'name', direction: 'ASC' },
80                     proxy : {
81                         xtype: 'HttpProxy',
82                         xns: Roo.data,
83                         method : 'GET',
84                         url : baseURL + '/Roo/Office.php'
85                     },
86                     reader : {
87                         xtype: 'JsonReader',
88                         xns: Roo.data,
89                         totalProperty : 'total',
90                         root : 'data',
91                         id : 'id',
92                         fields : [
93                             {
94                                 'name': 'id',
95                                 'type': 'int'
96                             },
97                             {
98                                 'name': 'company_id',
99                                 'type': 'int'
100                             },
101                             {
102                                 'name': 'name',
103                                 'type': 'string'
104                             },
105                             {
106                                 'name': 'address',
107                                 'type': 'string'
108                             },
109                             {
110                                 'name': 'phone',
111                                 'type': 'string'
112                             },
113                             {
114                                 'name': 'fax',
115                                 'type': 'string'
116                             },
117                             {
118                                 'name': 'email',
119                                 'type': 'string'
120                             },
121                             {
122                                 'name': 'role',
123                                 'type': 'string'
124                             },
125                             {
126                                 'name': 'company_id_code',
127                                 'type': 'string'
128                             },
129                             {
130                                 'name': 'company_id_name',
131                                 'type': 'string'
132                             },
133                             {
134                                 'name': 'company_id_remarks',
135                                 'type': 'string'
136                             },
137                             {
138                                 'name': 'company_id_owner_id',
139                                 'type': 'int'
140                             },
141                             {
142                                 'name': 'company_id_address',
143                                 'type': 'string'
144                             },
145                             {
146                                 'name': 'company_id_tel',
147                                 'type': 'string'
148                             },
149                             {
150                                 'name': 'company_id_fax',
151                                 'type': 'string'
152                             },
153                             {
154                                 'name': 'company_id_email',
155                                 'type': 'string'
156                             },
157                             {
158                                 'name': 'company_id_id',
159                                 'type': 'int'
160                             },
161                             {
162                                 'name': 'company_id_isOwner',
163                                 'type': 'int'
164                             },
165                             {
166                                 'name': 'company_id_logo_id',
167                                 'type': 'int'
168                             },
169                             {
170                                 'name': 'company_id_background_color',
171                                 'type': 'string'
172                             },
173                             {
174                                 'name': 'company_id_comptype',
175                                 'type': 'string'
176                             },
177                             {
178                                 'name': 'company_id_url',
179                                 'type': 'string'
180                             },
181                             {
182                                 'name': 'company_id_main_office_id',
183                                 'type': 'int'
184                             },
185                             {
186                                 'name': 'company_id_created_by',
187                                 'type': 'int'
188                             },
189                             {
190                                 'name': 'company_id_created_dt',
191                                 'type': 'date'
192                             },
193                             {
194                                 'name': 'company_id_updated_by',
195                                 'type': 'int'
196                             },
197                             {
198                                 'name': 'company_id_updated_dt',
199                                 'type': 'date'
200                             },
201                             {
202                                 'name': 'company_id_passwd',
203                                 'type': 'string'
204                             },
205                             {
206                                 'name': 'company_id_dispatch_port',
207                                 'type': 'string'
208                             },
209                             {
210                                 'name': 'company_id_province',
211                                 'type': 'string'
212                             },
213                             {
214                                 'name': 'company_id_country',
215                                 'type': 'string'
216                             }
217                         ]
218                     }
219                 },
220                 footer : {
221                     xtype: 'PagingToolbar',
222                     xns: Roo,
223                     pageSize : 25,
224                     displayInfo : true,
225                     displayMsg : "Displaying Office{0} - {1} of {2}",
226                     emptyMsg : "No Office found"
227                 },
228                 toolbar : {
229                     xtype: 'Toolbar',
230                     xns: Roo,
231                     items : [
232                         {
233                             xtype: 'Button',
234                             xns: Roo.Toolbar,
235                             listeners : {
236                                 click : function()
237                                 {
238                                     if (!_this.dialog) return;
239                                     
240                                     var cdata = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected().data;
241                                     _dialog.show( { 
242                                         id : 0 ,
243                                         company_name : cdata.name,
244                                         company_id : cdata.id,
245                                         address : cdata.address,
246                                         phone : cdata.tel,
247                                         fax : cdata.fax,
248                                         email  : cdata.email
249                                     } , function() {
250                                         _this.grid.footer.onClick('first');
251                                    });
252                                 }
253                             },
254                             cls : 'x-btn-text-icon',
255                             text : "Add",
256                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
257                         },
258                         {
259                             xtype: 'Button',
260                             xns: Roo.Toolbar,
261                             listeners : {
262                                 click : function()
263                                 {
264                                     var s = _this.grid.getSelectionModel().getSelections();
265                                     if (!s.length || (s.length > 1))  {
266                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
267                                         return;
268                                     }
269                                     if (!_this.dialog) return;
270                                     s[0].data.company_name = Pman.Tab.AdminCompanies.grid.getSelectionModel().getSelected().data.name;
271                                     _this.dialog.show(s[0].data, function() {
272                                         _this.grid.footer.onClick('first');
273                                     }); 
274                                     
275                                 }
276                             },
277                             cls : 'x-btn-text-icon',
278                             text : "Edit",
279                             icon : Roo.rootURL + 'images/default/tree/leaf.gif'
280                         },
281                         {
282                             xtype: 'Button',
283                             xns: Roo.Toolbar,
284                             text : "Delete",
285                             cls : 'x-btn-text-icon',
286                             icon : rootURL + '/Pman/templates/images/trash.gif',
287                             listeners : {
288                                 click : function()
289                                 {
290                                      Pman.genericDelete(_this, 'Office'); 
291                                 }
292                             }
293                         }
294                     ]
295                 },
296                 colModel : [
297                     {
298                         xtype: 'ColumnModel',
299                         xns: Roo.grid,
300                         dataIndex : 'name',
301                         header : 'Name / Department / Sub Comp.',
302                         sortable : true,
303                         width : 200,
304                         renderer : function(v) { return String.format('{0}', v); }
305                     },
306                     {
307                         xtype: 'ColumnModel',
308                         xns: Roo.grid,
309                         dataIndex : 'phone',
310                         header : 'Phone',
311                         width : 100,
312                         renderer : function(v) { return String.format('{0}', v); }
313                     },
314                     {
315                         xtype: 'ColumnModel',
316                         xns: Roo.grid,
317                         dataIndex : 'fax',
318                         header : 'Fax',
319                         width : 100,
320                         renderer : function(v) { return String.format('{0}', v); }
321                     },
322                     {
323                         xtype: 'ColumnModel',
324                         xns: Roo.grid,
325                         dataIndex : 'email',
326                         header : 'Email',
327                         width : 200,
328                         renderer : function (v) {
329                             return (v.length && v.indexOf('@') > 0 ) ? 
330                                 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
331                                 
332                         }
333                     },
334                     {
335                         xtype: 'ColumnModel',
336                         xns: Roo.grid,
337                         dataIndex : 'address',
338                         header : 'Address',
339                         width : 300,
340                         renderer : function(v) { return String.format('{0}', v); }
341                     }
342                 ]
343             }
344         };
345     }
346 });