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