Pman.Dialog.CoreCompanies.bjs
[Pman.Core] / Pman.Dialog.CoreCompanies.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.CoreCompanies = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             autoCreate : 'true',
34             closable : false,
35             collapsible : false,
36             draggable : false,
37             height : 400,
38             modal : true,
39             shadow : 'true',
40             title : "Edit Companies",
41             width : 750,
42             items : [
43                 {
44                     xtype: 'ContentPanel',
45                     xns: Roo,
46                     autoCreate : 'true',
47                     fitToFrame : true,
48                     region : 'center',
49                     items : [
50                         {
51                             xtype: 'Form',
52                             xns: Roo.form,
53                             listeners : {
54                                 actionfailed : function(f, act) {
55                                     _this.dialog.el.unmask();
56                                     // error msg???
57                                     Pman.standardActionFailed(f,act);
58                                               
59                                 },
60                                 actioncomplete : function(f, act) {
61                                     _this.dialog.el.unmask();
62                                     //console.log('load completed'); 
63                                     // error messages?????
64                                     
65                                    
66                                     if (act.type == 'load') {
67                                         
68                                         _this.data = act.result.data;
69                                         var meth = _this.data.isOwner || !Pman.Login.isOwner() ? 'disable' : 'enable';
70                                      
71                                             
72                                         if (_this.form.findField('comptype')) {
73                                             _this.form.findField('comptype')[meth]();
74                                         }
75                                          
76                                        // _this.loaded();
77                                         return;
78                                     }
79                                     
80                                     
81                                     if (act.type == 'submit') { // only submitted here if we are 
82                                         _this.dialog.hide();
83                                        
84                                         if (_this.callback) {
85                                             _this.callback.call(this, act.result.data);
86                                         }
87                                         return; 
88                                     }
89                                     // unmask?? 
90                                 },
91                                 rendered : function (form)
92                                 {
93                                     _this.form = form;
94                                 }
95                             },
96                             fileUpload : true,
97                             labelWidth : 160,
98                             items : [
99                                 {
100                                     xtype: 'TextField',
101                                     xns: Roo.form,
102                                     allowBlank : false,
103                                     fieldLabel : 'Company ID (for filing Ref.)',
104                                     name : 'code',
105                                     qtip : "Enter code",
106                                     width : 100
107                                 },
108                                 {
109                                     xtype: 'ComboBox',
110                                     xns: Roo.form,
111                                     allowBlank : false,
112                                     displayField : 'desc',
113                                     editable : false,
114                                     emptyText : "Select Type",
115                                     fieldLabel : 'Type',
116                                     hiddenName : 'comptype',
117                                     listWidth : 250,
118                                     name : 'comptype_name',
119                                     qtip : "Select Company type",
120                                     selectOnFocus : true,
121                                     triggerAction : 'all',
122                                     typeAhead : false,
123                                     valueField : 'val',
124                                     width : 200,
125                                     store : {
126                                         xtype: 'SimpleStore',
127                                         xns: Roo.data,
128                                         data : '[ \'CONSULTANT\', "Consultant" ],[ \'CLIENT\'    ,  "Client" ],[ \'CONTRACTOR\' , "Contractor" ]',
129                                         fields : '[\'val\', \'desc\']'
130                                     }
131                                 },
132                                 {
133                                     xtype: 'TextField',
134                                     xns: Roo.form,
135                                     allowBlank : true,
136                                     fieldLabel : 'Company Name',
137                                     name : 'name',
138                                     qtip : "Enter Company Name",
139                                     width : 300
140                                 },
141                                 {
142                                     xtype: 'TextField',
143                                     xns: Roo.form,
144                                     allowBlank : true,
145                                     fieldLabel : 'Company Name',
146                                     name : 'tel',
147                                     qtip : "Enter Company Name",
148                                     width : 300
149                                 }
150                             ]
151                         }
152                     ]
153                 }
154             ],
155             center : {
156                 xtype: 'LayoutRegion',
157                 xns: Roo,
158                 alwaysShowTabs : false,
159                 autoScroll : false,
160                 closeOnTab : true,
161                 hideTabs : true,
162                 titlebar : false
163             },
164             buttons : [
165                 {
166                     xtype: 'Button',
167                     xns: Roo,
168                     text : "Cancel"
169                 },
170                 {
171                     xtype: 'Button',
172                     xns: Roo,
173                     text : "Save"
174                 }
175             ]
176         });
177     }
178 };