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                                             fieldLabel : 'Background Colour',
204                                             name : 'background_color'
205                                         },
206                                         {
207                                             xtype: 'DisplayField',
208                                             xns: Roo.form,
209                                             fieldLabel : 'Logo Image',
210                                             height : 170,
211                                             icon : 'rootURL + \'images/default/dd/drop-add.gif\'',
212                                             name : 'logo_id',
213                                             style : 'border: 1px solid #ccc;',
214                                             width : 170,
215                                             valueRenderer : function(v) {
216                                                 //var vp = v ? v : 'Companies:' + _this.data.id + ':-LOGO';
217                                                 if (!v) {
218                                                     return "No Image Available" + '<BR/>';
219                                                 }
220                                                 return String.format('<img src="{0}" width="150">', 
221                                                         baseURL + '/Images/Thumb/150x150/' + v + '/logo.jpg'
222                                                 );
223                                             }
224                                         },
225                                         {
226                                             xtype: 'Button',
227                                             xns: Roo,
228                                             listeners : {
229                                                 click : function (_self, e)
230                                                 {
231                                                     var _t = _this.form.findField('logo_id');
232                                                                          
233                                                     Pman.Dialog.Image.show({
234                                                         onid :_this.data.id,
235                                                         ontable : 'Companies',
236                                                         imgtype : 'LOGO'
237                                                     }, function(data) {
238                                                         if  (data) {
239                                                             _t.setValue(data.id);
240                                                         }
241                                                         
242                                                     });
243                                                 }
244                                             },
245                                             text : "Add Image"
246                                         }
247                                     ]
248                                 },
249                                 {
250                                     xtype: 'Hidden',
251                                     xns: Roo.form,
252                                     name : 'isOwner'
253                                 },
254                                 {
255                                     xtype: 'Hidden',
256                                     xns: Roo.form,
257                                     name : 'id'
258                                 }
259                             ]
260                         }
261                     ]
262                 }
263             ],
264             center : {
265                 xtype: 'LayoutRegion',
266                 xns: Roo,
267                 alwaysShowTabs : false,
268                 autoScroll : false,
269                 closeOnTab : true,
270                 hideTabs : true,
271                 titlebar : false
272             },
273             buttons : [
274                 {
275                     xtype: 'Button',
276                     xns: Roo,
277                     text : "Cancel"
278                 },
279                 {
280                     xtype: 'Button',
281                     xns: Roo,
282                     text : "Save"
283                 }
284             ]
285         });
286     }
287 };