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 : 'Phone',
146                                     name : 'tel',
147                                     qtip : "Enter Phone Number",
148                                     width : 300
149                                 },
150                                 {
151                                     xtype: 'TextField',
152                                     xns: Roo.form,
153                                     allowBlank : true,
154                                     fieldLabel : 'Fax',
155                                     name : 'fax',
156                                     qtip : "Enter Fax Number",
157                                     width : 300
158                                 },
159                                 {
160                                     xtype: 'TextField',
161                                     xns: Roo.form,
162                                     allowBlank : true,
163                                     fieldLabel : 'Email',
164                                     name : 'email',
165                                     qtip : "Enter Email Address",
166                                     width : 300
167                                 },
168                                 {
169                                     xtype: 'TextField',
170                                     xns: Roo.form,
171                                     allowBlank : true,
172                                     fieldLabel : 'Address',
173                                     name : 'address',
174                                     qtip : "Enter Address",
175                                     width : 300
176                                 },
177                                 {
178                                     xtype: 'TextArea',
179                                     xns: Roo.form
180                                 }
181                             ]
182                         }
183                     ]
184                 }
185             ],
186             center : {
187                 xtype: 'LayoutRegion',
188                 xns: Roo,
189                 alwaysShowTabs : false,
190                 autoScroll : false,
191                 closeOnTab : true,
192                 hideTabs : true,
193                 titlebar : false
194             },
195             buttons : [
196                 {
197                     xtype: 'Button',
198                     xns: Roo,
199                     text : "Cancel"
200                 },
201                 {
202                     xtype: 'Button',
203                     xns: Roo,
204                     text : "Save"
205                 }
206             ]
207         });
208     }
209 };