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 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.CoreCompanies = {
8
9  _strings : {
10   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
11   '231bc72756b5e6de492aaaa1577f61b1' :"Remarks",
12   'b33457e7e1cd5dbf1db34a0c60fcb75f' :"Company ID (for filing Ref.)",
13   '023a5dfa857c4aa0156e6685231a1dbd' :"Select Type",
14   '8535bcc0f05358a583bb432bbadf7e0d' :"Select type",
15   '733640ec0c9367df1b4d85eb286ed9ae' :"Enter code",
16   '8c04eb09879a05470fae436ba76e3bb9' :"Enter Url",
17   '4ef6052d74436756f08e95fd63949653' :"Enter Company Name",
18   'c54b90756cfbeff9217293b567cb2eb0' :"Enter remarks",
19   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
20   'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
21   'cf3a5d25d39613ad5bbc2f5eb0f9b675' :"Enter Fax Number",
22   '9f86c00615b1a210935ac28ff8ebbb22' :"Enter Email Address",
23   'e7b47c58815acf1d3afa59a84b5db7fb' :"Company Name",
24   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
25   '32c4e9483403d60115b21519178e5384' :"Enter Address",
26   'b9c49611cfda3259a2b837b39489e650' :"Add Image",
27   '72b9d3d2e231f1de7a2bd70737f644aa' :"Add / Edit Organization",
28   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
29   '02a3a357710cc2a5dfdfb74ed012fb59' :"Url",
30   'dd7bf230fde8d4836917806aff6a6b27' :"Address",
31   'c9cc8cce247e49bae79f15173ce97354' :"Save",
32   'bc3a4c40d007b8d610a16312970e5cb3' :"Enter Phone Number",
33   '9810aa2b9f44401be4bf73188ef2b67d' :"Fax",
34   '35cb9e66ff801a819684ee0fbeabaeeb' :"Background Colour",
35   'bc87ef2144ae15ef4f78211e73948051' :"Logo Image"
36  },
37
38  dialog : false,
39  callback:  false,
40
41  show : function(data, cb)
42  {
43   if (!this.dialog) {
44    this.create();
45   }
46
47   this.callback = cb;
48   this.data = data;
49   this.dialog.show(this.data._el);
50   if (this.form) {
51    this.form.reset();
52    this.form.setValues(data);
53    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
54   }
55
56  },
57
58  create : function()
59  {
60    var _this = this;
61    this.dialog = Roo.factory({
62     xtype : 'LayoutDialog',
63     autoCreate : true,
64     closable : false,
65     collapsible : false,
66     draggable : false,
67     height : 400,
68     modal : true,
69     shadow : true,
70     title : _this._strings['72b9d3d2e231f1de7a2bd70737f644aa'] /* Add / Edit Organization */,
71     width : 750,
72     xns : Roo,
73     '|xns' : 'Roo',
74     center : {
75      xtype : 'LayoutRegion',
76      alwaysShowTabs : false,
77      autoScroll : false,
78      closeOnTab : true,
79      hideTabs : true,
80      titlebar : false,
81      xns : Roo,
82      '|xns' : 'Roo'
83     },
84     buttons : [
85      {
86       xtype : 'Button',
87       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
88       listeners : {
89        click : function (_self, e)
90         {
91             _this.dialog.hide();
92         }
93       },
94       xns : Roo,
95       '|xns' : 'Roo'
96      },
97      {
98       xtype : 'Button',
99       text : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
100       listeners : {
101        click : function (_self, e)
102         {
103             // do some checks?
104             
105             if(!_this.form.isValid()){
106                 Roo.MessageBox.alert('Error', 'Please Correct all the errors in red');
107                 return;
108             }
109             
110             
111             
112             _this.dialog.el.mask("Saving");
113             _this.form.doAction("submit");
114         
115         }
116       },
117       xns : Roo,
118       '|xns' : 'Roo'
119      }
120     ],
121     items  : [
122      {
123       xtype : 'ContentPanel',
124       autoCreate : true,
125       fitToFrame : true,
126       region : 'center',
127       xns : Roo,
128       '|xns' : 'Roo',
129       items  : [
130        {
131         xtype : 'Form',
132         fileUpload : true,
133         labelWidth : 160,
134         url : baseURL + '/Roo/Companies.php',
135         listeners : {
136          actioncomplete : function(f, act) {
137               _this.dialog.el.unmask();
138               //console.log('load completed'); 
139               // error messages?????
140               if(act.type == 'setdata'){
141                   this.load({ method: 'GET', params: { '_id' : _this.data.id }});
142                   return;
143               }
144              
145               if (act.type == 'load') {
146                   _this.data = act.result.data;
147                   var meth = _this.data.comptype == 'OWNER' ? 'disable' : 'enable';
148                
149                       
150                   if (_this.form.findField('comptype')) {
151                       _this.form.findField('comptype')[meth]();
152                   }
153                    
154                  // _this.loaded();
155                   return;
156               }
157               
158               
159               if (act.type == 'submit') { // only submitted here if we are 
160                   _this.dialog.hide();
161                  
162                   if (_this.callback) {
163                       _this.callback.call(this, act.result.data);
164                   }
165                   return; 
166               }
167               // unmask?? 
168           },
169          actionfailed : function(f, act) {
170               _this.dialog.el.unmask();
171               // error msg???
172               Pman.standardActionFailed(f,act);
173                         
174           },
175          rendered : function (form)
176           {
177               _this.form = form;
178           }
179         },
180         xns : Roo.form,
181         '|xns' : 'Roo.form',
182         items  : [
183          {
184           xtype : 'Column',
185           width : 500,
186           xns : Roo.form,
187           '|xns' : 'Roo.form',
188           items  : [
189            {
190             xtype : 'TextField',
191             allowBlank : true,
192             fieldLabel : _this._strings['b33457e7e1cd5dbf1db34a0c60fcb75f'] /* Company ID (for filing Ref.) */,
193             name : 'code',
194             qtip : _this._strings['733640ec0c9367df1b4d85eb286ed9ae'] /* Enter code */,
195             width : 100,
196             xns : Roo.form,
197             '|xns' : 'Roo.form'
198            },
199            {
200             xtype : 'ComboBox',
201             allowBlank : false,
202             alwaysQuery : true,
203             displayField : 'display_name',
204             emptyText : _this._strings['023a5dfa857c4aa0156e6685231a1dbd'] /* Select Type */,
205             fieldLabel : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
206             forceSelection : true,
207             hiddenName : 'comptype',
208             listWidth : 250,
209             loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
210             minChars : 2,
211             name : 'comptype_display_name',
212             pageSize : 20,
213             qtip : _this._strings['8535bcc0f05358a583bb432bbadf7e0d'] /* Select type */,
214             queryParam : 'query[name]',
215             selectOnFocus : true,
216             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> : {display_name}</div>',
217             triggerAction : 'all',
218             typeAhead : false,
219             valueField : 'name',
220             width : 200,
221             listeners : {
222              render : function (_self)
223               {
224                   _this.etypeCombo = _self;
225               }
226             },
227             xns : Roo.form,
228             '|xns' : 'Roo.form',
229             store : {
230              xtype : 'Store',
231              remoteSort : true,
232              sortInfo : { direction : 'ASC', field: 'id' },
233              listeners : {
234               beforeload : function (_self, o){
235                    o.params = o.params || {};
236                    // set more here
237                    //o.params['query[empty_etype]'] = 1;
238                    o.params.etype = 'COMPTYPE';
239                }
240              },
241              xns : Roo.data,
242              '|xns' : 'Roo.data',
243              proxy : {
244               xtype : 'HttpProxy',
245               method : 'GET',
246               url : baseURL + '/Roo/core_enum.php',
247               xns : Roo.data,
248               '|xns' : 'Roo.data'
249              },
250              reader : {
251               xtype : 'JsonReader',
252               fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
253               id : 'id',
254               root : 'data',
255               totalProperty : 'total',
256               xns : Roo.data,
257               '|xns' : 'Roo.data'
258              }
259             }
260            },
261            {
262             xtype : 'TextField',
263             allowBlank : false,
264             fieldLabel : _this._strings['e7b47c58815acf1d3afa59a84b5db7fb'] /* Company Name */,
265             name : 'name',
266             qtip : _this._strings['4ef6052d74436756f08e95fd63949653'] /* Enter Company Name */,
267             width : 300,
268             xns : Roo.form,
269             '|xns' : 'Roo.form'
270            },
271            {
272             xtype : 'TextField',
273             allowBlank : true,
274             fieldLabel : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
275             name : 'tel',
276             qtip : _this._strings['bc3a4c40d007b8d610a16312970e5cb3'] /* Enter Phone Number */,
277             width : 300,
278             xns : Roo.form,
279             '|xns' : 'Roo.form'
280            },
281            {
282             xtype : 'TextField',
283             allowBlank : true,
284             fieldLabel : _this._strings['9810aa2b9f44401be4bf73188ef2b67d'] /* Fax */,
285             name : 'fax',
286             qtip : _this._strings['cf3a5d25d39613ad5bbc2f5eb0f9b675'] /* Enter Fax Number */,
287             width : 300,
288             xns : Roo.form,
289             '|xns' : 'Roo.form'
290            },
291            {
292             xtype : 'TextField',
293             allowBlank : true,
294             fieldLabel : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
295             name : 'email',
296             qtip : _this._strings['9f86c00615b1a210935ac28ff8ebbb22'] /* Enter Email Address */,
297             width : 300,
298             xns : Roo.form,
299             '|xns' : 'Roo.form'
300            },
301            {
302             xtype : 'TextField',
303             allowBlank : true,
304             fieldLabel : _this._strings['02a3a357710cc2a5dfdfb74ed012fb59'] /* Url */,
305             name : 'url',
306             qtip : _this._strings['8c04eb09879a05470fae436ba76e3bb9'] /* Enter Url */,
307             width : 300,
308             xns : Roo.form,
309             '|xns' : 'Roo.form'
310            },
311            {
312             xtype : 'TextField',
313             allowBlank : true,
314             fieldLabel : _this._strings['dd7bf230fde8d4836917806aff6a6b27'] /* Address */,
315             name : 'address',
316             qtip : _this._strings['32c4e9483403d60115b21519178e5384'] /* Enter Address */,
317             width : 300,
318             xns : Roo.form,
319             '|xns' : 'Roo.form'
320            },
321            {
322             xtype : 'TextArea',
323             allowBlank : true,
324             fieldLabel : _this._strings['231bc72756b5e6de492aaaa1577f61b1'] /* Remarks */,
325             height : 120,
326             name : 'remarks',
327             qtip : _this._strings['c54b90756cfbeff9217293b567cb2eb0'] /* Enter remarks */,
328             width : 300,
329             xns : Roo.form,
330             '|xns' : 'Roo.form'
331            }
332           ]
333          },
334          {
335           xtype : 'Column',
336           labelAlign : 'top',
337           width : 200,
338           xns : Roo.form,
339           '|xns' : 'Roo.form',
340           items  : [
341            {
342             xtype : 'ColorField',
343             fieldLabel : _this._strings['35cb9e66ff801a819684ee0fbeabaeeb'] /* Background Colour */,
344             name : 'background_color',
345             xns : Roo.form,
346             '|xns' : 'Roo.form'
347            },
348            {
349             xtype : 'DisplayField',
350             fieldLabel : _this._strings['bc87ef2144ae15ef4f78211e73948051'] /* Logo Image */,
351             height : 170,
352             icon : 'rootURL + \'images/default/dd/drop-add.gif\'',
353             name : 'logo_id',
354             style : 'border: 1px solid #ccc;',
355             valueRenderer : function(v) {
356                 //var vp = v ? v : 'Companies:' + _this.data.id + ':-LOGO';
357                 if (!v) {
358                     return "No Image Available" + '<BR/>';
359                 }
360                 return String.format('<a target="_new" href="{1}"><img src="{0}" width="150"></a>', 
361                         baseURL + '/Images/Thumb/150x150/' + v + '/logo.jpg',
362                         baseURL + '/Images/'+v+'/logo.jpg'           // fixme - put escaped company name..
363                 );
364             },
365             width : 170,
366             xns : Roo.form,
367             '|xns' : 'Roo.form'
368            },
369            {
370             xtype : 'Button',
371             text : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
372             listeners : {
373              click : function (_self, e)
374               {
375                   var _t = _this.form.findField('logo_id');
376                                        
377                   Pman.Dialog.Image.show({
378                       onid :_this.data.id,
379                       ontable : 'Companies',
380                       imgtype : 'LOGO'
381                   }, function(data) {
382                       if  (data) {
383                           _t.setValue(data.id);
384                       }
385                       
386                   });
387               }
388             },
389             xns : Roo,
390             '|xns' : 'Roo'
391            }
392           ]
393          },
394          {
395           xtype : 'Hidden',
396           name : 'id',
397           xns : Roo.form,
398           '|xns' : 'Roo.form'
399          }
400         ]
401        }
402       ]
403      }
404     ]
405    });
406  }
407 };