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