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