Pman.Tab.AdminCompanies.js
[Pman.Admin] / Pman.Tab.AdminCompanies.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.AdminCompanies',
12         module : Pman.Tab.AdminCompanies,
13         region : 'center',
14         parent : false,
15         name : "unnamed module",
16         disabled : false, 
17         permname: '' 
18     });
19 });
20
21 Pman.Tab.AdminCompanies = 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: 'NestedLayoutPanel',
35             xns: Roo,
36             layout : {
37                 xtype: 'BorderLayout',
38                 xns: Roo,
39                 items : [
40                     {
41                         xtype: 'GridPanel',
42                         xns: Roo,
43                         title : "Companies",
44                         fitToframe : true,
45                         fitContainer : true,
46                         tableName : 'Companies',
47                         background : true,
48                         region : 'center',
49                         listeners : {
50                             activate : function() {
51                                 _this.panel = this;
52                                 if (_this.grid) {
53                                     _this.grid.footer.onClick('first');
54                                 }
55                             }
56                         },
57                         grid : {
58                             xtype: 'Grid',
59                             xns: Roo.grid,
60                             listeners : {
61                                 render : function() 
62                                 {
63                                     _this.grid = this; 
64                                     //_this.dialog = Pman.Dialog.FILL_IN
65                                     if (_this.panel.active) {
66                                        this.footer.onClick('first');
67                                     }
68                                 },
69                                 rowdblclick : function (_self, rowIndex, e)
70                                 {
71                                     if (!_this.dialog) return;
72                                     _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
73                                         _this.grid.footer.onClick('first');
74                                     }); 
75                                 }
76                             },
77                             autoExpandColumn : 'name',
78                             loadMask : true,
79                             dataSource : {
80                                 xtype: 'Store',
81                                 xns: Roo.data,
82                                 listeners : {
83                                     load : function (_self, records, options)
84                                     {
85                                        try {
86                                             Pman.Tab.Office.grid.footer.onClick('refresh');
87                                         } catch (e) {}
88                                     }
89                                 },
90                                 remoteSort : true,
91                                 sortInfo : { field : 'code', direction: 'ASC' },
92                                 proxy : {
93                                     xtype: 'HttpProxy',
94                                     xns: Roo.data,
95                                     listeners : {
96                                         load : function (This, o, arg)
97                                         {
98                                          
99                                         }
100                                     },
101                                     method : 'GET',
102                                     url : baseURL + '/Roo/Companies.php'
103                                 },
104                                 reader : {
105                                     xtype: 'JsonReader',
106                                     xns: Roo.data,
107                                     totalProperty : 'total',
108                                     root : 'data',
109                                     id : 'id',
110                                     fields : [
111                                         {
112                                             'name': 'code',
113                                             'type': 'string'
114                                         },
115                                         {
116                                             'name': 'name',
117                                             'type': 'string'
118                                         },
119                                         {
120                                             'name': 'remarks',
121                                             'type': 'string'
122                                         },
123                                         {
124                                             'name': 'owner_id',
125                                             'type': 'int'
126                                         },
127                                         {
128                                             'name': 'address',
129                                             'type': 'string'
130                                         },
131                                         {
132                                             'name': 'tel',
133                                             'type': 'string'
134                                         },
135                                         {
136                                             'name': 'fax',
137                                             'type': 'string'
138                                         },
139                                         {
140                                             'name': 'email',
141                                             'type': 'string'
142                                         },
143                                         {
144                                             'name': 'id',
145                                             'type': 'int'
146                                         },
147                                         {
148                                             'name': 'isOwner',
149                                             'type': 'int'
150                                         },
151                                         {
152                                             'name': 'logo_id',
153                                             'type': 'int'
154                                         },
155                                         {
156                                             'name': 'background_color',
157                                             'type': 'string'
158                                         },
159                                         {
160                                             'name': 'comptype',
161                                             'type': 'string'
162                                         },
163                                         {
164                                             'name': 'url',
165                                             'type': 'string'
166                                         },
167                                         {
168                                             'name': 'main_office_id',
169                                             'type': 'int'
170                                         },
171                                         {
172                                             'name': 'created_by',
173                                             'type': 'int'
174                                         },
175                                         {
176                                             'name': 'created_dt',
177                                             'type': 'date',
178                                             'dateFormat': 'Y-m-d'
179                                         },
180                                         {
181                                             'name': 'updated_by',
182                                             'type': 'int'
183                                         },
184                                         {
185                                             'name': 'updated_dt',
186                                             'type': 'date',
187                                             'dateFormat': 'Y-m-d'
188                                         },
189                                         {
190                                             'name': 'passwd',
191                                             'type': 'string'
192                                         },
193                                         {
194                                             'name': 'dispatch_port',
195                                             'type': 'string'
196                                         },
197                                         {
198                                             'name': 'province',
199                                             'type': 'string'
200                                         },
201                                         {
202                                             'name': 'country',
203                                             'type': 'string'
204                                         },
205                                         {
206                                             'name': 'logo_id_id',
207                                             'type': 'int'
208                                         },
209                                         {
210                                             'name': 'logo_id_filename',
211                                             'type': 'string'
212                                         },
213                                         {
214                                             'name': 'logo_id_ontable',
215                                             'type': 'string'
216                                         },
217                                         {
218                                             'name': 'logo_id_onid',
219                                             'type': 'int'
220                                         },
221                                         {
222                                             'name': 'logo_id_mimetype',
223                                             'type': 'string'
224                                         },
225                                         {
226                                             'name': 'logo_id_width',
227                                             'type': 'int'
228                                         },
229                                         {
230                                             'name': 'logo_id_height',
231                                             'type': 'int'
232                                         },
233                                         {
234                                             'name': 'logo_id_filesize',
235                                             'type': 'int'
236                                         },
237                                         {
238                                             'name': 'logo_id_displayorder',
239                                             'type': 'int'
240                                         },
241                                         {
242                                             'name': 'logo_id_language',
243                                             'type': 'string'
244                                         },
245                                         {
246                                             'name': 'logo_id_parent_image_id',
247                                             'type': 'int'
248                                         },
249                                         {
250                                             'name': 'logo_id_created',
251                                             'type': 'date'
252                                         },
253                                         {
254                                             'name': 'logo_id_imgtype',
255                                             'type': 'string'
256                                         },
257                                         {
258                                             'name': 'logo_id_linkurl',
259                                             'type': 'string'
260                                         },
261                                         {
262                                             'name': 'logo_id_descript',
263                                             'type': 'string'
264                                         },
265                                         {
266                                             'name': 'logo_id_title',
267                                             'type': 'string'
268                                         },
269                                         {
270                                             'name': 'owner_id_id',
271                                             'type': 'int'
272                                         },
273                                         {
274                                             'name': 'owner_id_office_id',
275                                             'type': 'int'
276                                         },
277                                         {
278                                             'name': 'owner_id_name',
279                                             'type': 'string'
280                                         },
281                                         {
282                                             'name': 'owner_id_phone',
283                                             'type': 'string'
284                                         },
285                                         {
286                                             'name': 'owner_id_fax',
287                                             'type': 'string'
288                                         },
289                                         {
290                                             'name': 'owner_id_email',
291                                             'type': 'string'
292                                         },
293                                         {
294                                             'name': 'owner_id_company_id',
295                                             'type': 'int'
296                                         },
297                                         {
298                                             'name': 'owner_id_role',
299                                             'type': 'string'
300                                         },
301                                         {
302                                             'name': 'owner_id_active',
303                                             'type': 'int'
304                                         },
305                                         {
306                                             'name': 'owner_id_remarks',
307                                             'type': 'string'
308                                         },
309                                         {
310                                             'name': 'owner_id_passwd',
311                                             'type': 'string'
312                                         },
313                                         {
314                                             'name': 'owner_id_owner_id',
315                                             'type': 'int'
316                                         },
317                                         {
318                                             'name': 'owner_id_lang',
319                                             'type': 'string'
320                                         },
321                                         {
322                                             'name': 'owner_id_no_reset_sent',
323                                             'type': 'int'
324                                         },
325                                         {
326                                             'name': 'owner_id_action_type',
327                                             'type': 'string'
328                                         },
329                                         {
330                                             'name': 'owner_id_project_id',
331                                             'type': 'int'
332                                         },
333                                         {
334                                             'name': 'owner_id_deleted_by',
335                                             'type': 'int'
336                                         },
337                                         {
338                                             'name': 'owner_id_deleted_dt',
339                                             'type': 'date'
340                                         },
341                                         {
342                                             'name': 'main_office_id_id',
343                                             'type': 'int'
344                                         },
345                                         {
346                                             'name': 'main_office_id_company_id',
347                                             'type': 'int'
348                                         },
349                                         {
350                                             'name': 'main_office_id_name',
351                                             'type': 'string'
352                                         },
353                                         {
354                                             'name': 'main_office_id_address',
355                                             'type': 'string'
356                                         },
357                                         {
358                                             'name': 'main_office_id_phone',
359                                             'type': 'string'
360                                         },
361                                         {
362                                             'name': 'main_office_id_fax',
363                                             'type': 'string'
364                                         },
365                                         {
366                                             'name': 'main_office_id_email',
367                                             'type': 'string'
368                                         },
369                                         {
370                                             'name': 'main_office_id_role',
371                                             'type': 'string'
372                                         }
373                                     ]
374                                 }
375                             },
376                             footer : {
377                                 xtype: 'PagingToolbar',
378                                 xns: Roo,
379                                 pageSize : 25,
380                                 displayInfo : true,
381                                 displayMsg : 'Displaying Companies{0} - {1} of {2}',
382                                 emptyMsg : 'No Companies found'
383                             },
384                             toolbar : {
385                                 xtype: 'Toolbar',
386                                 xns: Roo,
387                                 items : [
388                                     {
389                                         xtype: 'Button',
390                                         xns: Roo.Toolbar,
391                                         text : "Add",
392                                         cls : 'x-btn-text-icon',
393                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
394                                         listeners : {
395                                             click : function()
396                                             {
397                                                 if (!_this.dialog) return;
398                                                 _this.dialog.show( { id : 0 } , function() {
399                                                     _this.grid.footer.onClick('first');
400                                                }); 
401                                             }
402                                         }
403                                     },
404                                     {
405                                         xtype: 'Button',
406                                         xns: Roo.Toolbar,
407                                         text : "Edit",
408                                         cls : 'x-btn-text-icon',
409                                         icon : Roo.rootURL + 'images/default/tree/leaf.gif',
410                                         listeners : {
411                                             click : function()
412                                             {
413                                                 var s = _this.grid.getSelectionModel().getSelections();
414                                                 if (!s.length || (s.length > 1))  {
415                                                     Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
416                                                     return;
417                                                 }
418                                                 if (!_this.dialog) return;
419                                                 _this.dialog.show(s[0].data, function() {
420                                                     _this.grid.footer.onClick('first');
421                                                 }); 
422                                                 
423                                             }
424                                         }
425                                     },
426                                     {
427                                         xtype: 'Button',
428                                         xns: Roo.Toolbar,
429                                         text : "Delete",
430                                         cls : 'x-btn-text-icon',
431                                         icon : rootURL + '/Pman/templates/images/trash.gif',
432                                         listeners : {
433                                             click : function()
434                                             {
435                                                  Pman.genericDelete(_this, 'Companies'); 
436                                             }
437                                         }
438                                     }
439                                 ]
440                             },
441                             colModel : [
442                                 {
443                                     xtype: 'ColumnModel',
444                                     xns: Roo.grid,
445                                     dataIndex : 'comptype',
446                                     header : 'Type',
447                                     sortable : true,
448                                     width : 90,
449                                     renderer : function (v,x ,r) {
450                                         return Pman.Dialog.Companies.comptypeListToString(r.data.isOwner ? 'OWNER' : v);
451                                     }
452                                 },
453                                 {
454                                     xtype: 'ColumnModel',
455                                     xns: Roo.grid,
456                                     dataIndex : 'code',
457                                     header : 'Ref#',
458                                     width : 50,
459                                     renderer : function(v) { return String.format('{0}', v); }
460                                 },
461                                 {
462                                     xtype: 'ColumnModel',
463                                     xns: Roo.grid,
464                                     dataIndex : 'name',
465                                     header : 'Name',
466                                     width : 200,
467                                     renderer : function(v,x,r) {
468                                         return String.format(r.data.isOwner ? '<B>{0}</B>' : '{0}',v);    
469                                     }
470                                 },
471                                 {
472                                     xtype: 'ColumnModel',
473                                     xns: Roo.grid,
474                                     dataIndex : 'tel',
475                                     header : 'Tel',
476                                     width : 100,
477                                     renderer : function(v) { return String.format('{0}', v); }
478                                 },
479                                 {
480                                     xtype: 'ColumnModel',
481                                     xns: Roo.grid,
482                                     dataIndex : 'fax',
483                                     header : 'Fax',
484                                     width : 100,
485                                     renderer : function(v) { return String.format('{0}', v); }
486                                 },
487                                 {
488                                     xtype: 'ColumnModel',
489                                     xns: Roo.grid,
490                                     dataIndex : 'email',
491                                     header : 'Email',
492                                     width : 100,
493                                     renderer : function (v) {
494                                             return (v.length && v.indexOf('@') > 0 ) ? 
495                                                 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
496                                                 
497                                         }
498                                 },
499                                 {
500                                     xtype: 'ColumnModel',
501                                     xns: Roo.grid,
502                                     header : 'Address',
503                                     width : 200,
504                                     dataIndex : 'address',
505                                     renderer : function(v) { return String.format('{0}', v); }
506                                 },
507                                 {
508                                     xtype: 'ColumnModel',
509                                     xns: Roo.grid,
510                                     header : 'Remarks',
511                                     width : 200,
512                                     dataIndex : 'remarks',
513                                     renderer : function(v) { return String.format('{0}', v); }
514                                 }
515                             ]
516                         }
517                     }
518                 ],
519                 center : {
520                     xtype: 'LayoutRegion',
521                     xns: Roo
522                 },
523                 south : {
524                     xtype: 'LayoutRegion',
525                     xns: Roo
526                 }
527             }
528         });
529         this.layout = this.panel.layout;
530
531     }
532 });