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