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