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