Pman.Dialog.BAdminEmail.bjs
[Pman.BAdmin] / Pman.Dialog.BAdminEmail.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.BAdminEmail= function() {}
8 Roo.apply(Pman.Dialog.BAdminEmail.prototype, {
9
10  _strings : {
11   '843627586c62e389041a4d8800143974' :"Searching",
12   '2c466a2c159463f1d9ef5a7b57b52827' :"Select BCC Group",
13   '396ecabf0cd1f9503e591418851ef406' :"Edit / Create Message",
14   '3858712080cb3d846ea206d1d1070674' :"Test Class (for system reference only):",
15   '31fde7b05ac8952dacf4af8a704074ec' :"Preview",
16   '5b8ef4e762c00a15a41cfc26dc3ef99c' :"Send me a test copy",
17   '4182c8f19d40c7ca236a5f4f83faeb6b' :"Unsubscribe",
18   'b2bce8099bf8e6f51345bee5c9015c89' :"Convert HTML to Plain Text",
19   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
20   'c4ca4238a0b923820dcc509a6f75849b' :"1",
21   '1e6d57e813355689e9c77e947d73ad8f' :"From:",
22   '292f75d54a6892cfe18a93e64230112a' :"Mailout Name:",
23   '47a0be8d1015d526a1fbaa56c3102135' :"Subject:",
24   '5feb9bf3c03b32635135006cbacb9542' :"Insert Field",
25   '7038eac66e387c3b3a0834d786a88757' :"Insert Image",
26   'e71c729cd7f3c6b6ebdb447e65952dfd' :"From email address:",
27   'edddfc18b2ffb806573a1b3f341832cd' :"BCC to Group:",
28   'bd88a20b53a47f7b5704a83a15ff5506' :"Saved Version",
29   'e44b145bd8b49b06e0ad2ced1ad56466' :"Plain Text",
30   'c9cc8cce247e49bae79f15173ce97354' :"Save",
31   '49ee3087348e8d44e1feda1917443987' :"Name",
32   'fb981fe689fbec75c6531eb7410971f4' :"To group:",
33   'e05f77bdf3f659c1fd354a88526c03da' :"Select Group",
34   '36a65bbd12f7586ea1f9b0be4e8848aa' :"HTML Editor"
35  },
36
37  dialog : false,
38  callback:  false,
39
40  show : function(data, cb)
41  {
42   if (!this.dialog) {
43    this.create();
44   }
45
46   this.callback = cb;
47   this.data = data;
48   this.dialog.show(this.data._el);
49   if (this.form) {
50    this.form.reset();
51    this.form.setValues(data);
52    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
53   }
54
55  },
56
57  create : function()
58  {
59   var _this = this;
60   this.dialog = Roo.factory({
61     xtype : 'Modal',
62     cls : 'modal-body-enable-overflow-y',
63     fitwindow : true,
64     title : _this._strings['396ecabf0cd1f9503e591418851ef406'] /* Edit / Create Message */,
65     listeners : {
66      hide : function (_self)
67       {
68           if(_this.autosave) {
69               
70               clearInterval(_this.autosave);
71           }
72       },
73      render : function (_self)
74       {
75       
76       },
77      show : function (_self)
78       {
79       
80       }
81     },
82     xns : Roo.bootstrap,
83     '|xns' : 'Roo.bootstrap',
84     buttons : [
85      {
86       xtype : 'Button',
87       html : _this._strings['5b8ef4e762c00a15a41cfc26dc3ef99c'] /* Send me a test copy */,
88       name : 'send',
89       weight : 'default',
90       listeners : {
91        click : function (_self, e)
92         {
93             //_this.dialog.hide();
94         
95             var id = _this.form.findField('id').getValue();
96             
97             if(id*1 < 1){
98                 Roo.bootstrap.MessageBox.alert('Error', 'Please save the message first!');
99                 return;
100             }
101            
102             new Pman.Request({
103                 url : baseURL + '/Core/MessagePreview',
104                 method : 'POST',
105                 mask: 'Sending',
106                 params : {
107                     _id : id,
108                     _table : _this.data.module
109                 }, 
110                 success : function(res) {
111                     if(res.data == 'SUCCESS'){
112                         Roo.bootstrap.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
113                     }
114                 }
115             });
116         }
117       },
118       xns : Roo.bootstrap,
119       '|xns' : 'Roo.bootstrap'
120      },
121      {
122       xtype : 'Button',
123       html : _this._strings['31fde7b05ac8952dacf4af8a704074ec'] /* Preview */,
124       name : 'preview',
125       weight : 'default',
126       listeners : {
127        click : function (_self, e)
128         {
129             Pman.Dialog.BAdminEmailPreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });
130         }
131       },
132       xns : Roo.bootstrap,
133       '|xns' : 'Roo.bootstrap'
134      },
135      {
136       xtype : 'Button',
137       html : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
138       name : 'cancel',
139       weight : 'default',
140       listeners : {
141        click : function (_self, e)
142         {
143             _this.dialog.hide();
144         }
145       },
146       xns : Roo.bootstrap,
147       '|xns' : 'Roo.bootstrap'
148      },
149      {
150       xtype : 'Button',
151       html : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
152       name : 'save',
153       weight : 'primary',
154       listeners : {
155        click : function (_self, e)
156         {
157             _this.form.preValidate(function(res) {
158                 if (!res) {
159                     return; //failed.
160                 }
161             });
162         }
163       },
164       xns : Roo.bootstrap,
165       '|xns' : 'Roo.bootstrap'
166      }
167     ],
168     items  : [
169      {
170       xtype : 'Container',
171       xns : Roo.bootstrap,
172       '|xns' : 'Roo.bootstrap',
173       items  : [
174        {
175         xtype : 'Form',
176         errorMask : true,
177         hideshow : function()
178         {
179             _this.to_group_row.hide();
180             
181             if (this.findField('to_group').getValue() == -1) {
182                 return;
183             }
184             
185             _this.to_group_row.show();
186         },
187         method : 'POST',
188         preValidate : function(done_callback) {
189             
190             if(!_this.form.findField('bodytext').editorcore.sourceEditMode){
191                 _this.form.findField('bodytext').syncValue();
192             }else{
193                 _this.form.findField('bodytext').pushValue();
194             }
195             
196             var html = _this.form.findField('bodytext').getValue();
197             
198             var s = Roo.get(_this.form.findField('bodytext').editorcore.doc.documentElement);
199             
200             var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
201             
202             
203             var nodes = [];
204             
205             s.select('img[src]').each(function(i) {
206                 nodes.push(i.dom);
207             });
208             
209             
210             var total = nodes.length;
211             
212             var mkimg = function() {
213                 if (!nodes.length) {
214                       _this.form.findField('bodytext').syncValue();
215                       done_callback(true);
216                       _this.form.doAction("submit");
217                       return;
218                 }
219                 var i = nodes.pop(); 
220                 
221                 var n = i.getAttribute('src').match(/(baseURL|server_baseurl)/);
222                 
223                 if(n){
224                     mkimg();
225                     return;
226                 }
227                 
228                 n = i.getAttribute('src').match(/^http(.*)/);
229                
230                 if(!n ){
231                     mkimg();
232                     return;
233                 }
234                 
235                 
236                 
237                 new Pman.Request({
238                     url : baseURL + '/Roo/Images.php',
239                     method : 'POST',
240                     params : {
241                         onid : _this.form.findField('id').getValue(),
242                         ontable : ontable ,
243                         _remote_upload : i.src
244                     },
245                     success : function(res){
246                         if(res.success == true){      
247                             i.setAttribute('src', res.data);
248                         }
249                         mkimg();
250                     }
251                 });
252                
253             }
254             mkimg();
255         },
256         url : baseURL + '/Roo/crm_mailing_list_message.php',
257         listeners : {
258          actioncomplete : function(_self,action)
259           {
260              
261               if (action.type == 'setdata') {
262                   
263                   _this.data.module = _this.data.module || 'crm_mailing_list_message';
264                   this.url = baseURL + '/Roo/' + _this.data.module;
265                   
266                   if(_this.data.id*1 > 0){
267                       _this.dialog.el.mask("Loading");
268                       this.doAction(
269                           'load',
270                           { method: 'GET', params: { '_id' : _this.data.id, '_with_css' : 1 }}
271                       );
272                       return;
273                   }
274                   
275                   this.findField('name').setDisabled(false);
276                   this.findField('test_class').setDisabled(false);
277                   
278                   this.reset();
279                   
280                   this.findField('to_group').setValue(-1);
281                   this.findField('bodytext').setValue('');
282                   
283                   this.setValues({
284                       'from_name' : Pman.Login.authUser.name,
285                       'from_email' : Pman.Login.authUser.email
286                   });
287                   
288                   this.clearInvalid();
289                   
290                   this.hideshow();
291                   
292                   return;
293               }
294               
295               if (action.type == 'load') {
296                   
297                   this.findField('name').setDisabled(false);
298                   this.findField('test_class').setDisabled(false);
299                   
300                   if(action.result.data['is_system'] == 1) {
301                       this.findField('name').setDisabled(true);
302                       this.findField('test_class').setDisabled(true);
303                   }
304                   
305                   _this.dialog.el.unmask();
306                   
307                   this.findField('bodytext').originalValue = this.findField('bodytext').getValue();
308                   
309                   _this.form_data = action.result.data;
310                   
311                   if(_this.form_data._css && _this.form_data._css.length){
312                       _this.htmleditor.editorcore.setStyle(_this.form_data._css);
313                   }
314                   
315                   this.findField('_ignore_group_count').setValue('0');
316                   
317                   this.hideshow();
318                   
319                   return;
320               }
321               
322               if (action.type =='submit') {
323               
324                   _this.dialog.el.unmask();
325                   _this.dialog.hide();
326                   
327                    if (_this.callback) {
328                       _this.callback.call(_this, action.result.data);
329                    }
330                    
331                    this.reset();
332                    
333                    return;
334               }
335           },
336          actionfailed : function (_self, action)
337           {
338           
339              var displayErr = function() {
340                  if(action.result.errorMsg.length >= 200) {
341                      Roo.bootstrap.MessageBox.alert("Error", action.result.errorMsg.substring(0,199) + '...');
342                  } else {
343                      Roo.bootstrap.MessageBox.alert("Error", action.result.errorMsg);
344                  }
345              }
346              switch(action.failureType) {
347               case Roo.form.Action.SERVER_INVALID: 
348                  if(action.result.errors.errcode) {
349                      switch (action.result.errors.errcode) {
350                          case 100:
351                              Roo.bootstrap.MessageBox.confirm('Confirm Save', 'No member found in To Group: ' + _this.combo_to_group.getRawValue() ,function(ret) {
352                                  if(ret == 'no'){
353                                      return;
354                                  }
355                                  _this.form.findField('_ignore_group_count').setValue('1');
356                                  _this.form.doAction("submit");                       
357                              }, this);
358                          break;
359                          
360                          default:
361                              displayErr();
362                              break;
363                      }
364                      return;
365                  }
366                  displayErr();
367                  
368                  break;
369               case Roo.form.Action.CLIENT_INVALID: //for validation
370                  break;
371               case Roo.form.Action.CONNECT_FAILURE:
372                  Roo.bootstrap.MessageBox.alert("Connect Error", action.result.errorMsg);
373                  break;
374               default: 
375                  Roo.bootstrap.MessageBox.alert("Error", action.result.errorMsg);
376                  break;
377                  
378               }
379           },
380          render : function (_self)
381           {
382               _this.form = this;
383           }
384         },
385         xns : Roo.bootstrap,
386         '|xns' : 'Roo.bootstrap',
387         items  : [
388          {
389           xtype : 'Row',
390           xns : Roo.bootstrap,
391           '|xns' : 'Roo.bootstrap',
392           items  : [
393            {
394             xtype : 'Column',
395             md : 8,
396             xs : 12,
397             xns : Roo.bootstrap,
398             '|xns' : 'Roo.bootstrap',
399             items  : [
400              {
401               xtype : 'Input',
402               allowBlank : false,
403               fieldLabel : _this._strings['292f75d54a6892cfe18a93e64230112a'] /* Mailout Name: */,
404               indicatorpos : 'right',
405               labelWidth : 3,
406               name : 'name',
407               xns : Roo.bootstrap,
408               '|xns' : 'Roo.bootstrap'
409              }
410             ]
411            },
412            {
413             xtype : 'Column',
414             md : 4,
415             xns : Roo.bootstrap,
416             '|xns' : 'Roo.bootstrap',
417             items  : [
418              {
419               xtype : 'CheckBox',
420               boxLabel : 'Enabled - will be sent out',
421               checked : true,
422               indicatorpos : 'right',
423               name : 'active',
424               value : 1,
425               valueOff : 0,
426               listeners : {
427                check : function (_self, checked)
428                 {
429                     var boxLabel = 'Enabled - will be sent out';
430                     
431                     if(!checked){
432                         boxLabel = 'Disabled - will NOT be sent out';
433                     }
434                     
435                     //this.setBoxLabel(boxLabel);
436                 }
437               },
438               xns : Roo.bootstrap,
439               '|xns' : 'Roo.bootstrap'
440              }
441             ]
442            }
443           ]
444          },
445          {
446           xtype : 'Row',
447           xns : Roo.bootstrap,
448           '|xns' : 'Roo.bootstrap',
449           items  : [
450            {
451             xtype : 'Column',
452             md : 6,
453             name : 'from_name',
454             xs : 12,
455             xns : Roo.bootstrap,
456             '|xns' : 'Roo.bootstrap',
457             items  : [
458              {
459               xtype : 'Input',
460               allowBlank : false,
461               fieldLabel : _this._strings['1e6d57e813355689e9c77e947d73ad8f'] /* From: */,
462               indicatorpos : 'right',
463               labelWidth : 4,
464               name : 'from_name',
465               xns : Roo.bootstrap,
466               '|xns' : 'Roo.bootstrap'
467              }
468             ]
469            },
470            {
471             xtype : 'Column',
472             md : 6,
473             xs : 12,
474             xns : Roo.bootstrap,
475             '|xns' : 'Roo.bootstrap',
476             items  : [
477              {
478               xtype : 'Input',
479               allowBlank : false,
480               fieldLabel : _this._strings['e71c729cd7f3c6b6ebdb447e65952dfd'] /* From email address: */,
481               indicatorpos : 'right',
482               labelWidth : 4,
483               name : 'from_email',
484               vtype : 'email',
485               xns : Roo.bootstrap,
486               '|xns' : 'Roo.bootstrap'
487              }
488             ]
489            }
490           ]
491          },
492          {
493           xtype : 'Row',
494           xns : Roo.bootstrap,
495           '|xns' : 'Roo.bootstrap',
496           items  : [
497            {
498             xtype : 'Column',
499             md : 6,
500             xs : 12,
501             listeners : {
502              render : function (_self)
503               {
504                   _this.to_group_row = this;
505               }
506             },
507             xns : Roo.bootstrap,
508             '|xns' : 'Roo.bootstrap',
509             items  : [
510              {
511               xtype : 'ComboBox',
512               allowBlank : true,
513               alwaysQuery : true,
514               displayField : 'name',
515               editable : false,
516               fieldLabel : _this._strings['fb981fe689fbec75c6531eb7410971f4'] /* To group: */,
517               forceSelection : true,
518               hiddenName : 'to_group_id',
519               labelAlign : 'left',
520               labelWidth : 4,
521               loadingText : _this._strings['843627586c62e389041a4d8800143974'] /* Searching */,
522               minChars : 2,
523               name : 'to_group_id_name',
524               pageSize : 20,
525               placeholder : _this._strings['e05f77bdf3f659c1fd354a88526c03da'] /* Select Group */,
526               triggerAction : 'all',
527               typeAhead : true,
528               valueField : 'id',
529               listeners : {
530                render : function (_self)
531                 {
532                     _this.combo_to_group = _self;
533                 }
534               },
535               xns : Roo.bootstrap,
536               '|xns' : 'Roo.bootstrap',
537               store : {
538                xtype : 'Store',
539                remoteSort : true,
540                sortInfo : { direction : 'ASC', field: 'name' },
541                listeners : {
542                 beforeload : function (_self, o){
543                      o.params = o.params || {};
544                      
545                      o.params._direct_return = 1;
546                  }
547                },
548                xns : Roo.data,
549                '|xns' : 'Roo.data',
550                proxy : {
551                 xtype : 'HttpProxy',
552                 method : 'GET',
553                 url : baseURL + '/Roo/Core_group',
554                 xns : Roo.data,
555                 '|xns' : 'Roo.data'
556                },
557                reader : {
558                 xtype : 'JsonReader',
559                 fields : [{"name":"name","type":"string"},{"name":"id","type":"int"}],
560                 id : 'name',
561                 root : 'data',
562                 totalProperty : 'total',
563                 xns : Roo.data,
564                 '|xns' : 'Roo.data'
565                }
566               }
567              }
568             ]
569            },
570            {
571             xtype : 'Column',
572             md : 6,
573             xs : 12,
574             xns : Roo.bootstrap,
575             '|xns' : 'Roo.bootstrap',
576             items  : [
577              {
578               xtype : 'ComboBox',
579               allowBlank : true,
580               alwaysQuery : true,
581               displayField : 'name',
582               editable : false,
583               fieldLabel : _this._strings['edddfc18b2ffb806573a1b3f341832cd'] /* BCC to Group: */,
584               forceSelection : true,
585               hiddenName : 'bcc_group_id',
586               labelAlign : 'left',
587               labelWidth : 4,
588               loadingText : _this._strings['843627586c62e389041a4d8800143974'] /* Searching */,
589               minChars : 2,
590               name : 'bcc_group_id_name',
591               pageSize : 20,
592               placeholder : _this._strings['2c466a2c159463f1d9ef5a7b57b52827'] /* Select BCC Group */,
593               triggerAction : 'all',
594               typeAhead : true,
595               valueField : 'id',
596               xns : Roo.bootstrap,
597               '|xns' : 'Roo.bootstrap',
598               store : {
599                xtype : 'Store',
600                remoteSort : true,
601                sortInfo : { direction : 'ASC', field: 'name' },
602                listeners : {
603                 beforeload : function (_self, o){
604                      o.params = o.params || {};
605                      
606                      o.params._direct_return = 1;
607                  }
608                },
609                xns : Roo.data,
610                '|xns' : 'Roo.data',
611                proxy : {
612                 xtype : 'HttpProxy',
613                 method : 'GET',
614                 url : baseURL + '/Roo/Core_group',
615                 xns : Roo.data,
616                 '|xns' : 'Roo.data'
617                },
618                reader : {
619                 xtype : 'JsonReader',
620                 fields : [{"name":"name","type":"string"},{"name":"id","type":"int"}],
621                 id : 'name',
622                 root : 'data',
623                 totalProperty : 'total',
624                 xns : Roo.data,
625                 '|xns' : 'Roo.data'
626                }
627               }
628              }
629             ]
630            }
631           ]
632          },
633          {
634           xtype : 'Row',
635           xns : Roo.bootstrap,
636           '|xns' : 'Roo.bootstrap',
637           items  : [
638            {
639             xtype : 'Column',
640             md : 12,
641             xs : 12,
642             xns : Roo.bootstrap,
643             '|xns' : 'Roo.bootstrap',
644             items  : [
645              {
646               xtype : 'Input',
647               allowBlank : false,
648               fieldLabel : _this._strings['47a0be8d1015d526a1fbaa56c3102135'] /* Subject: */,
649               indicatorpos : 'right',
650               labelWidth : 2,
651               name : 'subject',
652               xns : Roo.bootstrap,
653               '|xns' : 'Roo.bootstrap'
654              }
655             ]
656            }
657           ]
658          },
659          {
660           xtype : 'Row',
661           xns : Roo.bootstrap,
662           '|xns' : 'Roo.bootstrap',
663           items  : [
664            {
665             xtype : 'Column',
666             md : 12,
667             xns : Roo.bootstrap,
668             '|xns' : 'Roo.bootstrap',
669             items  : [
670              {
671               xtype : 'Container',
672               header : _this._strings['36a65bbd12f7586ea1f9b0be4e8848aa'] /* HTML Editor */,
673               panel : 'default',
674               xns : Roo.bootstrap,
675               '|xns' : 'Roo.bootstrap',
676               items  : [
677                {
678                 xtype : 'HtmlEditor',
679                 bodyCls : 'roo-email',
680                 name : 'bodytext',
681                 stylesheets : '',
682                 listeners : {
683                  autosave : function (_self)
684                   {
685                       Roo.log('autosave');
686                       
687                       var id = _this.form.findField('id').getValue() * 1;
688                       
689                       new Pman.Request({
690                           url : baseURL + '/Roo/Events.php',
691                           method :'POST',
692                           params : {
693                               id : 0,
694                               action : 'AUTOSAVE',
695                               on_id : (id > 0) ? id : 0,
696                               on_table : 'crm_mailing_list_message',
697                               remarks : 'BODY',
698                               source: _self.getValue()
699                           },
700                           success : function() {
701                               _self.originalValue = _self.getValue();
702                               
703                           },
704                           failure : function() 
705                           {
706                               Roo.log('body autosave failed?!');
707                           }
708                       });
709                       
710                   },
711                  render : function (_self)
712                   {
713                       _this.htmleditor = this;
714                   },
715                  savedpreview : function (_self)
716                   {
717                       var id = _this.form.findField('id').getValue() * 1;
718                       
719                       var successFn = function(res){
720                           return res.data.POST.source;
721                       };
722                       
723                       var params = {
724                           action : 'AUTOSAVE',
725                           remarks : 'BODY',
726                           on_id : (id < 1) ? 0 : id,
727                           on_table : 'core_email',
728                           successFn : successFn
729                       };
730                       
731                       
732                       Pman.Dialog.BAdminAutoSavePreview.show(params, function(res){
733                           _self.setValue(res);
734                           _self.originalValue = res;
735                       });
736                   }
737                 },
738                 xns : Roo.bootstrap,
739                 '|xns' : 'Roo.bootstrap',
740                 btns : [
741                  {
742                   xtype : 'Button',
743                   glyphicon : 'camera',
744                   html : _this._strings['7038eac66e387c3b3a0834d786a88757'] /* Insert Image */,
745                   toggle : false,
746                   listeners : {
747                    click : function (_self, e)
748                     {
749                         if (!_this.form.findField('bodytext').editorcore.activated) {
750                             Roo.bootstrap.MessageBox.alert('Cannot add any image', 'Please select a place in the belowing text area where the image will insert at');
751                             return;
752                         }
753                         
754                         var id = _this.form.findField('id').getValue();
755                         
756                         if(id*1 < 1){
757                             Roo.bootstrap.MessageBox.alert('Cannot add any image', 'Please save the email template first');
758                             return;
759                         }
760                         
761                         var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
762                         
763                         Pman.Dialog.BAdminImageManager.show({
764                             id : 0,
765                             onid: id,
766                             ontable: ontable
767                         });
768                         
769                     }
770                   },
771                   xns : Roo.bootstrap,
772                   '|xns' : 'Roo.bootstrap'
773                  },
774                  {
775                   xtype : 'Button',
776                   glyphicon : 'tag',
777                   html : _this._strings['5feb9bf3c03b32635135006cbacb9542'] /* Insert Field */,
778                   toggle : false,
779                   xns : Roo.bootstrap,
780                   '|xns' : 'Roo.bootstrap',
781                   menu : {
782                    xtype : 'Menu',
783                    xns : Roo.bootstrap,
784                    '|xns' : 'Roo.bootstrap',
785                    items  : [
786                     {
787                      xtype : 'MenuItem',
788                      html : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
789                      listeners : {
790                       click : function (_self, e)
791                        {
792                            if (!_this.form.findField('bodytext').editorcore.activated) {
793                                Roo.bootstrap.MessageBox.alert('Cannot add the name tag', 'Please select a place in the belowing text area where the tag will insert at');
794                                return;
795                            }
796                            
797                            _this.form.findField('bodytext').editorcore.insertAtCursor(
798                                String.format('{0}',
799                                    '{person.name}'
800                                )
801                            );
802                        }
803                      },
804                      xns : Roo.bootstrap,
805                      '|xns' : 'Roo.bootstrap'
806                     },
807                     {
808                      xtype : 'MenuItem',
809                      html : _this._strings['4182c8f19d40c7ca236a5f4f83faeb6b'] /* Unsubscribe */,
810                      listeners : {
811                       click : function (_self, e)
812                        {
813                            if (!_this.form.findField('bodytext').editorcore.activated) {
814                                Roo.bootstrap.MessageBox.alert('Cannot add the unsubscribe tag', 'Please select a place in the belowing text area where the tag will insert at');
815                                return;
816                            }
817                            
818                            _this.form.findField('bodytext').editorcore.insertAtCursor(
819                                String.format('<a href="{0}">{1}</a>',
820                                    '#unsubscribe',  "Unsubscribe"
821                                )
822                            );
823                        }
824                      },
825                      xns : Roo.bootstrap,
826                      '|xns' : 'Roo.bootstrap'
827                     }
828                    ]
829                   }
830                  },
831                  {
832                   xtype : 'Button',
833                   glyphicon : 'refresh',
834                   html : _this._strings['b2bce8099bf8e6f51345bee5c9015c89'] /* Convert HTML to Plain Text */,
835                   toggle : false,
836                   listeners : {
837                    click : function (_self, e)
838                     {
839                         var h = _this.form.findField('bodytext').getValue();
840                         var p = _this.form.findField('plaintext');
841                         
842                         new Pman.Request({\r
843                             url : baseURL + '/Core/ImportMailMessage.php',\r
844                             method : 'POST',\r
845                             params : {
846                               bodytext : h,\r
847                               _convertToPlain : true,
848                               _check_unsubscribe : true\r
849                             }, \r
850                             success : function(res) {\r
851                                 if(res.success == true){
852                                    p.setValue(res.data);
853                                 }\r
854                             }\r
855                         });
856                         
857                     }
858                   },
859                   xns : Roo.bootstrap,
860                   '|xns' : 'Roo.bootstrap'
861                  },
862                  {
863                   xtype : 'Button',
864                   glyphicon : 'floppy-disk',
865                   html : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
866                   toggle : false,
867                   listeners : {
868                    click : function (_self, e)
869                     {
870                         this.scope.owner.fireEvent('savedpreview', this.scope.owner);
871                     }
872                   },
873                   xns : Roo.bootstrap,
874                   '|xns' : 'Roo.bootstrap'
875                  }
876                 ]
877                }
878               ]
879              }
880             ]
881            }
882           ]
883          },
884          {
885           xtype : 'Row',
886           listeners : {
887            click : function (_self, e)
888             {
889                 var h = _this.form.findField('bodytext').getValue();
890                 var p = _this.form.findField('plaintext');
891                 
892                 new Pman.Request({\r
893                     url : baseURL + '/Core/ImportMailMessage.php',\r
894                     method : 'POST',\r
895                     params : {
896                       bodytext : h,\r
897                       _convertToPlain : true,
898                       _check_unsubscribe : true\r
899                     }, \r
900                     success : function(res) {\r
901                         if(res.success == true){
902                            p.setValue(res.data);
903                         }\r
904                     }\r
905                 });
906                 
907             }
908           },
909           xns : Roo.bootstrap,
910           '|xns' : 'Roo.bootstrap',
911           items  : [
912            {
913             xtype : 'Column',
914             md : 12,
915             xns : Roo.bootstrap,
916             '|xns' : 'Roo.bootstrap',
917             items  : [
918              {
919               xtype : 'Container',
920               header : _this._strings['e44b145bd8b49b06e0ad2ced1ad56466'] /* Plain Text */,
921               panel : 'default',
922               xns : Roo.bootstrap,
923               '|xns' : 'Roo.bootstrap',
924               items  : [
925                {
926                 xtype : 'TextArea',
927                 name : 'plaintext',
928                 xns : Roo.bootstrap,
929                 '|xns' : 'Roo.bootstrap'
930                }
931               ]
932              }
933             ]
934            }
935           ]
936          },
937          {
938           xtype : 'Row',
939           xns : Roo.bootstrap,
940           '|xns' : 'Roo.bootstrap',
941           items  : [
942            {
943             xtype : 'Column',
944             md : 12,
945             xns : Roo.bootstrap,
946             '|xns' : 'Roo.bootstrap',
947             items  : [
948              {
949               xtype : 'Input',
950               fieldLabel : _this._strings['3858712080cb3d846ea206d1d1070674'] /* Test Class (for system reference only): */,
951               labelAlign : 'top',
952               name : 'test_class',
953               xns : Roo.bootstrap,
954               '|xns' : 'Roo.bootstrap'
955              }
956             ]
957            }
958           ]
959          },
960          {
961           xtype : 'Input',
962           inputType : 'hidden',
963           labelWidth : 3,
964           name : 'id',
965           xns : Roo.bootstrap,
966           '|xns' : 'Roo.bootstrap'
967          },
968          {
969           xtype : 'Input',
970           inputType : 'hidden',
971           labelWidth : 3,
972           name : '_ignore_group_count',
973           xns : Roo.bootstrap,
974           '|xns' : 'Roo.bootstrap'
975          }
976         ]
977        }
978       ]
979      }
980     ]
981    }  );
982  }
983 });
984 Roo.apply(Pman.Dialog.BAdminEmail, Pman.Dialog.BAdminEmail.prototype);