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