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