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