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