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