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