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