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.grid.footer.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                                             
408                                             },
409                                             specialkey : function (_self, e)
410                                             {
411                                              if (e.getKey() == 13) {
412                                                  _this.grid.footer.onClick( 'first' );
413                                               }
414                                             },
415                                             render : function (_self)
416                                             {
417                                             _this.searchBox = _self;
418                                             }
419                                         }
420                                     },
421                                     {
422                                         xtype: 'Button',
423                                         xns: Roo.Toolbar,
424                                         listeners : {
425                                             click : function (_self, e)
426                                             {
427                                             _this.grid.footer.onClick('first');
428                                             }
429                                         },
430                                         cls : 'x-btn-icon',
431                                         icon : rootURL + '/Pman/templates/images/search.gif'
432                                     },
433                                     {
434                                         xtype: 'Button',
435                                         xns: Roo.Toolbar,
436                                         listeners : {
437                                             click : function (_self, e)
438                                             {
439                                                 _this.searchBox.setValue('');
440                                                 _this.grid.footer.onClick('first');
441                                             }
442                                         },
443                                         cls : 'x-btn-icon',
444                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif'
445                                     },
446                                     {
447                                         xtype: 'Fill',
448                                         xns: Roo.Toolbar
449                                     },
450                                     {
451                                         xtype: 'Button',
452                                         xns: Roo.Toolbar,
453                                         text : "Add",
454                                         cls : 'x-btn-text-icon',
455                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
456                                         listeners : {
457                                             click : function()
458                                             {
459                                                 if (!_this.dialog) return;
460                                                 _this.dialog.show( { id : 0 } , function() {
461                                                     _this.grid.footer.onClick('first');
462                                                }); 
463                                             }
464                                         }
465                                     },
466                                     {
467                                         xtype: 'Button',
468                                         xns: Roo.Toolbar,
469                                         listeners : {
470                                             click : function()
471                                             {
472                                                 var s = _this.grid.getSelectionModel().getSelections();
473                                                 if (!s.length || (s.length > 1))  {
474                                                     Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
475                                                     return;
476                                                 }
477                                                 if (!_this.dialog) return;
478                                                 _this.dialog.show(s[0].data, function() {
479                                                     _this.grid.footer.onClick('first');
480                                                 }); 
481                                                 
482                                             }
483                                         },
484                                         cls : 'x-btn-text-icon',
485                                         text : "Edit",
486                                         icon : Roo.rootURL + 'images/default/tree/leaf.gif'
487                                     },
488                                     {
489                                         xtype: 'Button',
490                                         xns: Roo.Toolbar,
491                                         text : "Delete",
492                                         cls : 'x-btn-text-icon',
493                                         icon : rootURL + '/Pman/templates/images/trash.gif',
494                                         listeners : {
495                                             click : function()
496                                             {
497                                                  Pman.genericDelete(_this, 'Companies'); 
498                                             }
499                                         }
500                                     }
501                                 ]
502                             },
503                             colModel : [
504                                 {
505                                     xtype: 'ColumnModel',
506                                     xns: Roo.grid,
507                                     dataIndex : 'comptype',
508                                     header : 'Type',
509                                     sortable : true,
510                                     width : 90,
511                                     renderer : function (v,x ,r) {
512                                         return Pman.Dialog.Companies.comptypeListToString(r.data.isOwner ? 'OWNER' : v);
513                                     }
514                                 },
515                                 {
516                                     xtype: 'ColumnModel',
517                                     xns: Roo.grid,
518                                     dataIndex : 'code',
519                                     header : 'Ref#',
520                                     sortable : true,
521                                     width : 50,
522                                     renderer : function(v) { return String.format('{0}', v); }
523                                 },
524                                 {
525                                     xtype: 'ColumnModel',
526                                     xns: Roo.grid,
527                                     dataIndex : 'name',
528                                     header : 'Name',
529                                     sortable : true,
530                                     width : 200,
531                                     renderer : function(v,x,r) {
532                                         return String.format(r.data.isOwner ? '<B>{0}</B>' : '{0}',v);    
533                                     }
534                                 },
535                                 {
536                                     xtype: 'ColumnModel',
537                                     xns: Roo.grid,
538                                     dataIndex : 'tel',
539                                     header : 'Tel',
540                                     width : 100,
541                                     renderer : function(v) { return String.format('{0}', v); }
542                                 },
543                                 {
544                                     xtype: 'ColumnModel',
545                                     xns: Roo.grid,
546                                     dataIndex : 'fax',
547                                     header : 'Fax',
548                                     width : 100,
549                                     renderer : function(v) { return String.format('{0}', v); }
550                                 },
551                                 {
552                                     xtype: 'ColumnModel',
553                                     xns: Roo.grid,
554                                     dataIndex : 'email',
555                                     header : 'Email',
556                                     sortable : true,
557                                     width : 100,
558                                     renderer : function (v) {
559                                             return (v.length && v.indexOf('@') > 0 ) ? 
560                                                 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
561                                                 
562                                         }
563                                 },
564                                 {
565                                     xtype: 'ColumnModel',
566                                     xns: Roo.grid,
567                                     dataIndex : 'address',
568                                     header : 'Address',
569                                     sortable : true,
570                                     width : 200,
571                                     renderer : function(v) { return String.format('{0}', v); }
572                                 },
573                                 {
574                                     xtype: 'ColumnModel',
575                                     xns: Roo.grid,
576                                     header : 'Remarks',
577                                     width : 200,
578                                     dataIndex : 'remarks',
579                                     renderer : function(v) { return String.format('{0}', v); }
580                                 }
581                             ]
582                         }
583                     }
584                 ],
585                 center : {
586                     xtype: 'LayoutRegion',
587                     xns: Roo
588                 },
589                 south : {
590                     xtype: 'LayoutRegion',
591                     xns: Roo,
592                     height : 150,
593                     split : true,
594                     titlebar : true
595                 }
596             }
597         });
598         this.layout = this.panel.layout;
599
600     }
601 });