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