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 : true,
103                                     fieldLabel : 'Phone',
104                                     name : 'tel',
105                                     qtip : "Enter Phone Number",
106                                     width : 300
107                                 },
108                                 {
109                                     xtype: 'TextField',
110                                     xns: Roo.form,
111                                     allowBlank : true,
112                                     fieldLabel : 'Fax',
113                                     name : 'fax',
114                                     qtip : "Enter Fax Number",
115                                     width : 300
116                                 },
117                                 {
118                                     xtype: 'TextField',
119                                     xns: Roo.form,
120                                     allowBlank : true,
121                                     fieldLabel : 'Email',
122                                     name : 'email',
123                                     qtip : "Enter Email Address",
124                                     width : 300
125                                 },
126                                 {
127                                     xtype: 'TextField',
128                                     xns: Roo.form,
129                                     allowBlank : true,
130                                     fieldLabel : 'Address',
131                                     name : 'address',
132                                     qtip : "Enter Address",
133                                     width : 300
134                                 },
135                                 {
136                                     xtype: 'TextArea',
137                                     xns: Roo.form,
138                                     allowBlank : true,
139                                     fieldLabel : 'Remarks',
140                                     height : 40,
141                                     name : 'remarks',
142                                     qtip : "Enter remarks",
143                                     width : 300
144                                 },
145                                 {
146                                     xtype: 'Column',
147                                     xns: Roo.form,
148                                     items : [
149                                         {
150                                             xtype: 'TextField',
151                                             xns: Roo.form,
152                                             allowBlank : false,
153                                             fieldLabel : 'Company ID (for filing Ref.)',
154                                             name : 'code',
155                                             qtip : "Enter code",
156                                             width : 100
157                                         },
158                                         {
159                                             xtype: 'ComboBox',
160                                             xns: Roo.form,
161                                             allowBlank : false,
162                                             displayField : 'desc',
163                                             editable : false,
164                                             emptyText : "Select Type",
165                                             fieldLabel : 'Type',
166                                             hiddenName : 'comptype',
167                                             listWidth : 250,
168                                             name : 'comptype_name',
169                                             qtip : "Select Company type",
170                                             selectOnFocus : true,
171                                             triggerAction : 'all',
172                                             typeAhead : false,
173                                             valueField : 'val',
174                                             width : 200,
175                                             store : {
176                                                 xtype: 'SimpleStore',
177                                                 xns: Roo.data,
178                                                 data : '[ \'CONSULTANT\', "Consultant" ],[ \'CLIENT\'    ,  "Client" ],[ \'CONTRACTOR\' , "Contractor" ]',
179                                                 fields : '[\'val\', \'desc\']'
180                                             }
181                                         },
182                                         {
183                                             xtype: 'TextField',
184                                             xns: Roo.form,
185                                             allowBlank : true,
186                                             fieldLabel : 'Company Name',
187                                             name : 'name',
188                                             qtip : "Enter Company Name",
189                                             width : 300
190                                         },
191                                         {
192                                             xtype: 'TextField',
193                                             xns: Roo.form,
194                                             allowBlank : true,
195                                             fieldLabel : 'Phone',
196                                             name : 'tel',
197                                             qtip : "Enter Phone Number",
198                                             width : 300
199                                         },
200                                         {
201                                             xtype: 'TextField',
202                                             xns: Roo.form,
203                                             allowBlank : true,
204                                             fieldLabel : 'Fax',
205                                             name : 'fax',
206                                             qtip : "Enter Fax Number",
207                                             width : 300
208                                         },
209                                         {
210                                             xtype: 'TextField',
211                                             xns: Roo.form,
212                                             allowBlank : true,
213                                             fieldLabel : 'Email',
214                                             name : 'email',
215                                             qtip : "Enter Email Address",
216                                             width : 300
217                                         },
218                                         {
219                                             xtype: 'TextField',
220                                             xns: Roo.form,
221                                             allowBlank : true,
222                                             fieldLabel : 'Address',
223                                             name : 'address',
224                                             qtip : "Enter Address",
225                                             width : 300
226                                         },
227                                         {
228                                             xtype: 'TextArea',
229                                             xns: Roo.form,
230                                             allowBlank : true,
231                                             fieldLabel : 'Remarks',
232                                             height : 40,
233                                             name : 'remarks',
234                                             qtip : "Enter remarks",
235                                             width : 300
236                                         }
237                                     ]
238                                 }
239                             ]
240                         }
241                     ]
242                 }
243             ],
244             center : {
245                 xtype: 'LayoutRegion',
246                 xns: Roo,
247                 alwaysShowTabs : false,
248                 autoScroll : false,
249                 closeOnTab : true,
250                 hideTabs : true,
251                 titlebar : false
252             },
253             buttons : [
254                 {
255                     xtype: 'Button',
256                     xns: Roo,
257                     text : "Cancel"
258                 },
259                 {
260                     xtype: 'Button',
261                     xns: Roo,
262                     text : "Save"
263                 }
264             ]
265         });
266     }
267 };