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