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