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