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