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