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