BS4 support
[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   '47a0be8d1015d526a1fbaa56c3102135' :"Subject:",
23   '5feb9bf3c03b32635135006cbacb9542' :"Insert Field",
24   '292f75d54a6892cfe18a93e64230112a' :"Mailout Name:",
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   'b5a7adde1af5c87d7fd797b6245c2a39' :"Description",
32   '49ee3087348e8d44e1feda1917443987' :"Name",
33   '28690be026c0bb9003aa58e45e5662ca' :"Enabled - will be sent out",
34   'fb981fe689fbec75c6531eb7410971f4' :"To group:",
35   'e05f77bdf3f659c1fd354a88526c03da' :"Select Group",
36   '36a65bbd12f7586ea1f9b0be4e8848aa' :"HTML Editor"
37  },
38  _named_strings : {
39   'description_fieldLabel' : 'b5a7adde1af5c87d7fd797b6245c2a39' /* Description */ ,
40   'active_boxLabel' : '28690be026c0bb9003aa58e45e5662ca' /* Enabled - will be sent out */ ,
41   'to_group_id_name_loadingText' : '843627586c62e389041a4d8800143974' /* Searching */ ,
42   'to_group_id_name_fieldLabel' : 'fb981fe689fbec75c6531eb7410971f4' /* To group: */ ,
43   'save_html' : 'c9cc8cce247e49bae79f15173ce97354' /* Save */ ,
44   'bcc_group_id_name_placeholder' : '2c466a2c159463f1d9ef5a7b57b52827' /* Select BCC Group */ ,
45   'name_fieldLabel' : '292f75d54a6892cfe18a93e64230112a' /* Mailout Name: */ ,
46   'cancel_html' : 'ea4788705e6873b424c65e91c2846b19' /* Cancel */ ,
47   'from_email_fieldLabel' : 'e71c729cd7f3c6b6ebdb447e65952dfd' /* From email address: */ ,
48   'to_group_id_name_placeholder' : 'e05f77bdf3f659c1fd354a88526c03da' /* Select Group */ ,
49   'preview_html' : '31fde7b05ac8952dacf4af8a704074ec' /* Preview */ ,
50   'active_value' : 'c4ca4238a0b923820dcc509a6f75849b' /* 1 */ ,
51   'send_html' : '5b8ef4e762c00a15a41cfc26dc3ef99c' /* Send me a test copy */ ,
52   'from_name_fieldLabel' : '1e6d57e813355689e9c77e947d73ad8f' /* From: */ ,
53   'bcc_group_id_name_loadingText' : '843627586c62e389041a4d8800143974' /* Searching */ ,
54   'bcc_group_id_name_fieldLabel' : 'edddfc18b2ffb806573a1b3f341832cd' /* BCC to Group: */ ,
55   'subject_fieldLabel' : '47a0be8d1015d526a1fbaa56c3102135' /* Subject: */ ,
56   'test_class_fieldLabel' : '3858712080cb3d846ea206d1d1070674' /* Test Class (for system reference only): */ 
57  },
58
59  dialog : false,
60  callback:  false,
61
62  show : function(data, cb)
63  {
64   if (!this.dialog) {
65    this.create();
66   }
67
68   this.callback = cb;
69   this.data = data;
70   this.dialog.show(this.data._el);
71   if (this.form) {
72    this.form.reset();
73    this.form.setValues(data);
74    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
75   }
76
77  },
78
79  create : function()
80  {
81   var _this = this;
82   this.dialog = Roo.factory({
83     xtype : 'Modal',
84     cls : 'modal-body-enable-overflow-y',
85     fitwindow : true,
86     title : _this._strings['396ecabf0cd1f9503e591418851ef406'] /* Edit / Create Message */,
87     listeners : {
88      hide : function (_self)
89       {
90           if(_this.autosave) {
91               
92               clearInterval(_this.autosave);
93           }
94       },
95      render : function (_self)
96       {
97       
98       },
99      show : function (_self)
100       {
101       
102       }
103     },
104     xns : Roo.bootstrap,
105     '|xns' : 'Roo.bootstrap',
106     buttons : [
107      {
108       xtype : 'Button',
109       html : _this._strings['5b8ef4e762c00a15a41cfc26dc3ef99c'] /* Send me a test copy */,
110       name : 'send',
111       weight : 'default',
112       listeners : {
113        click : function (_self, e)
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                   /*
318                   this.findField('name').setDisabled(false);
319                   this.findField('test_class').setDisabled(false);
320                   
321                   if(action.result.data['is_system'] == 1) {
322                       this.findField('name').setDisabled(true);
323                       this.findField('test_class').setDisabled(true);
324                   }
325                   */
326                   
327                   _this.dialog.el.unmask();
328                   
329                   this.findField('bodytext').originalValue = this.findField('bodytext').getValue();
330                   
331                   _this.form_data = action.result.data;
332                   
333                   if(_this.form_data._css && _this.form_data._css.length){
334                       _this.htmleditor.editorcore.setStyle(_this.form_data._css);
335                   }
336                   
337                   this.findField('_ignore_group_count').setValue('0');
338                   
339                   if(!_this.form_data.description.length){
340                       _this.form_data.findField('description').setValue(_this.form_data.name);
341                   }
342                   
343                   this.hideshow();
344                   
345                   return;
346               }
347               
348               if (action.type =='submit') {
349               
350                   _this.dialog.el.unmask();
351                   _this.dialog.hide();
352                   
353                    if (_this.callback) {
354                       _this.callback.call(_this, action.result.data);
355                    }
356                    
357                    this.reset();
358                    
359                    return;
360               }
361           },
362          actionfailed : function (_self, action)
363           {
364           
365              var displayErr = function() {
366                  if(action.result.errorMsg.length >= 200) {
367                      Roo.bootstrap.MessageBox.alert("Error", action.result.errorMsg.substring(0,199) + '...');
368                  } else {
369                      Roo.bootstrap.MessageBox.alert("Error", action.result.errorMsg);
370                  }
371              }
372              switch(action.failureType) {
373               case Roo.form.Action.SERVER_INVALID: 
374                  if(action.result.errors.errcode) {
375                      switch (action.result.errors.errcode) {
376                          case 100:
377                              
378                              Roo.bootstrap.MessageBox.show({
379                                  title: 'Confirm Save',
380                                  msg: 'No member found in To Group: '+ _this.combo_to_group.getRawValue(),
381                                  buttons: {yes:'OK Save anyway', no:'Change to another group'},
382                                  fn: function(ret){
383                                      
384                                      if(ret == 'no'){
385                                          return;
386                                      }
387                                       
388                                      _this.form.findField('_ignore_group_count').setValue('1');
389                                      _this.form.doAction("submit");                       
390                                  }
391                              });
392                            
393                              
394                          break;
395                          
396                          default:
397                              displayErr();
398                              break;
399                      }
400                      return;
401                  }
402                  displayErr();
403                  
404                  break;
405               case Roo.form.Action.CLIENT_INVALID: //for validation
406                  break;
407               case Roo.form.Action.CONNECT_FAILURE:
408                  Roo.bootstrap.MessageBox.alert("Connect Error", action.result.errorMsg);
409                  break;
410               default: 
411                  Roo.bootstrap.MessageBox.alert("Error", action.result.errorMsg);
412                  break;
413                  
414               }
415           },
416          render : function (_self)
417           {
418               _this.form = this;
419           }
420         },
421         xns : Roo.bootstrap,
422         '|xns' : 'Roo.bootstrap',
423         items  : [
424          {
425           xtype : 'Row',
426           xns : Roo.bootstrap,
427           '|xns' : 'Roo.bootstrap',
428           items  : [
429            {
430             xtype : 'Column',
431             md : 8,
432             xs : 12,
433             xns : Roo.bootstrap,
434             '|xns' : 'Roo.bootstrap',
435             items  : [
436              {
437               xtype : 'Input',
438               allowBlank : false,
439               fieldLabel : _this._strings['b5a7adde1af5c87d7fd797b6245c2a39'] /* Description */,
440               indicatorpos : 'right',
441               labelWidth : 3,
442               name : 'description',
443               xns : Roo.bootstrap,
444               '|xns' : 'Roo.bootstrap'
445              }
446             ]
447            },
448            {
449             xtype : 'Column',
450             md : 4,
451             xns : Roo.bootstrap,
452             '|xns' : 'Roo.bootstrap',
453             items  : [
454              {
455               xtype : 'CheckBox',
456               boxLabel : _this._strings['28690be026c0bb9003aa58e45e5662ca'] /* Enabled - will be sent out */,
457               checked : true,
458               indicatorpos : 'right',
459               name : 'active',
460               value : 1,
461               valueOff : 0,
462               listeners : {
463                check : function (_self, checked)
464                 {
465                     var boxLabel = 'Enabled - will be sent out';
466                     
467                     if(!checked){
468                         boxLabel = 'Disabled - will NOT be sent out';
469                     }
470                     
471                     //this.setBoxLabel(boxLabel);
472                 }
473               },
474               xns : Roo.bootstrap,
475               '|xns' : 'Roo.bootstrap'
476              }
477             ]
478            }
479           ]
480          },
481          {
482           xtype : 'Row',
483           xns : Roo.bootstrap,
484           '|xns' : 'Roo.bootstrap',
485           items  : [
486            {
487             xtype : 'Column',
488             md : 6,
489             name : 'from_name',
490             xs : 12,
491             xns : Roo.bootstrap,
492             '|xns' : 'Roo.bootstrap',
493             items  : [
494              {
495               xtype : 'Input',
496               allowBlank : false,
497               fieldLabel : _this._strings['1e6d57e813355689e9c77e947d73ad8f'] /* From: */,
498               indicatorpos : 'right',
499               labelWidth : 4,
500               name : 'from_name',
501               xns : Roo.bootstrap,
502               '|xns' : 'Roo.bootstrap'
503              }
504             ]
505            },
506            {
507             xtype : 'Column',
508             md : 6,
509             xs : 12,
510             xns : Roo.bootstrap,
511             '|xns' : 'Roo.bootstrap',
512             items  : [
513              {
514               xtype : 'Input',
515               allowBlank : false,
516               fieldLabel : _this._strings['e71c729cd7f3c6b6ebdb447e65952dfd'] /* From email address: */,
517               indicatorpos : 'right',
518               labelWidth : 4,
519               name : 'from_email',
520               vtype : 'email',
521               xns : Roo.bootstrap,
522               '|xns' : 'Roo.bootstrap'
523              }
524             ]
525            }
526           ]
527          },
528          {
529           xtype : 'Row',
530           xns : Roo.bootstrap,
531           '|xns' : 'Roo.bootstrap',
532           items  : [
533            {
534             xtype : 'Column',
535             md : 6,
536             xs : 12,
537             listeners : {
538              render : function (_self)
539               {
540                   _this.to_group_row = this;
541               }
542             },
543             xns : Roo.bootstrap,
544             '|xns' : 'Roo.bootstrap',
545             items  : [
546              {
547               xtype : 'ComboBox',
548               allowBlank : true,
549               alwaysQuery : true,
550               displayField : 'name',
551               editable : false,
552               fieldLabel : _this._strings['fb981fe689fbec75c6531eb7410971f4'] /* To group: */,
553               forceSelection : true,
554               hiddenName : 'to_group_id',
555               indicatorpos : 'right',
556               labelAlign : 'left',
557               labelWidth : 4,
558               loadingText : _this._strings['843627586c62e389041a4d8800143974'] /* Searching */,
559               minChars : 2,
560               name : 'to_group_id_name',
561               pageSize : 20,
562               placeholder : _this._strings['e05f77bdf3f659c1fd354a88526c03da'] /* Select Group */,
563               triggerAction : 'all',
564               typeAhead : true,
565               valueField : 'id',
566               listeners : {
567                render : function (_self)
568                 {
569                     _this.combo_to_group = _self;
570                 }
571               },
572               xns : Roo.bootstrap,
573               '|xns' : 'Roo.bootstrap',
574               store : {
575                xtype : 'Store',
576                remoteSort : true,
577                sortInfo : { direction : 'ASC', field: 'name' },
578                listeners : {
579                 beforeload : function (_self, o){
580                      o.params = o.params || {};
581                      
582                      o.params._direct_return = 1;
583                  }
584                },
585                xns : Roo.data,
586                '|xns' : 'Roo.data',
587                proxy : {
588                 xtype : 'HttpProxy',
589                 method : 'GET',
590                 url : baseURL + '/Roo/Core_group',
591                 xns : Roo.data,
592                 '|xns' : 'Roo.data'
593                },
594                reader : {
595                 xtype : 'JsonReader',
596                 fields : [{"name":"name","type":"string"},{"name":"id","type":"int"}],
597                 id : 'name',
598                 root : 'data',
599                 totalProperty : 'total',
600                 xns : Roo.data,
601                 '|xns' : 'Roo.data'
602                }
603               }
604              }
605             ]
606            },
607            {
608             xtype : 'Column',
609             md : 6,
610             xs : 12,
611             xns : Roo.bootstrap,
612             '|xns' : 'Roo.bootstrap',
613             items  : [
614              {
615               xtype : 'ComboBox',
616               allowBlank : true,
617               alwaysQuery : true,
618               displayField : 'name',
619               editable : false,
620               fieldLabel : _this._strings['edddfc18b2ffb806573a1b3f341832cd'] /* BCC to Group: */,
621               forceSelection : true,
622               hiddenName : 'bcc_group_id',
623               indicatorpos : 'right',
624               labelAlign : 'left',
625               labelWidth : 4,
626               loadingText : _this._strings['843627586c62e389041a4d8800143974'] /* Searching */,
627               minChars : 2,
628               name : 'bcc_group_id_name',
629               pageSize : 20,
630               placeholder : _this._strings['2c466a2c159463f1d9ef5a7b57b52827'] /* Select BCC Group */,
631               triggerAction : 'all',
632               typeAhead : true,
633               valueField : 'id',
634               xns : Roo.bootstrap,
635               '|xns' : 'Roo.bootstrap',
636               store : {
637                xtype : 'Store',
638                remoteSort : true,
639                sortInfo : { direction : 'ASC', field: 'name' },
640                listeners : {
641                 beforeload : function (_self, o){
642                      o.params = o.params || {};
643                      
644                      o.params._direct_return = 1;
645                  }
646                },
647                xns : Roo.data,
648                '|xns' : 'Roo.data',
649                proxy : {
650                 xtype : 'HttpProxy',
651                 method : 'GET',
652                 url : baseURL + '/Roo/Core_group',
653                 xns : Roo.data,
654                 '|xns' : 'Roo.data'
655                },
656                reader : {
657                 xtype : 'JsonReader',
658                 fields : [{"name":"name","type":"string"},{"name":"id","type":"int"}],
659                 id : 'name',
660                 root : 'data',
661                 totalProperty : 'total',
662                 xns : Roo.data,
663                 '|xns' : 'Roo.data'
664                }
665               }
666              }
667             ]
668            }
669           ]
670          },
671          {
672           xtype : 'Row',
673           xns : Roo.bootstrap,
674           '|xns' : 'Roo.bootstrap',
675           items  : [
676            {
677             xtype : 'Column',
678             md : 12,
679             xs : 12,
680             xns : Roo.bootstrap,
681             '|xns' : 'Roo.bootstrap',
682             items  : [
683              {
684               xtype : 'Input',
685               allowBlank : false,
686               fieldLabel : _this._strings['47a0be8d1015d526a1fbaa56c3102135'] /* Subject: */,
687               indicatorpos : 'right',
688               labelWidth : 2,
689               name : 'subject',
690               xns : Roo.bootstrap,
691               '|xns' : 'Roo.bootstrap'
692              }
693             ]
694            }
695           ]
696          },
697          {
698           xtype : 'Row',
699           xns : Roo.bootstrap,
700           '|xns' : 'Roo.bootstrap',
701           items  : [
702            {
703             xtype : 'Column',
704             md : 12,
705             xns : Roo.bootstrap,
706             '|xns' : 'Roo.bootstrap',
707             items  : [
708              {
709               xtype : 'Container',
710               header : _this._strings['36a65bbd12f7586ea1f9b0be4e8848aa'] /* HTML Editor */,
711               panel : 'default',
712               xns : Roo.bootstrap,
713               '|xns' : 'Roo.bootstrap',
714               items  : [
715                {
716                 xtype : 'HtmlEditor',
717                 bodyCls : 'roo-email',
718                 name : 'bodytext',
719                 stylesheets : '',
720                 listeners : {
721                  autosave : function (_self)
722                   {
723                       Roo.log('autosave');
724                       
725                       var id = _this.form.findField('id').getValue() * 1;
726                       
727                       new Pman.Request({
728                           url : baseURL + '/Roo/Events.php',
729                           method :'POST',
730                           params : {
731                               id : 0,
732                               action : 'AUTOSAVE',
733                               on_id : (id > 0) ? id : 0,
734                               on_table : 'crm_mailing_list_message',
735                               remarks : 'BODY',
736                               source: _self.getValue()
737                           },
738                           success : function() {
739                               _self.originalValue = _self.getValue();
740                               
741                           },
742                           failure : function() 
743                           {
744                               Roo.log('body autosave failed?!');
745                           }
746                       });
747                       
748                   },
749                  render : function (_self)
750                   {
751                       _this.htmleditor = this;
752                   },
753                  savedpreview : function (_self)
754                   {
755                       var id = _this.form.findField('id').getValue() * 1;
756                       
757                       var successFn = function(res){
758                           return res.data.POST.source;
759                       };
760                       
761                       var params = {
762                           action : 'AUTOSAVE',
763                           remarks : 'BODY',
764                           on_id : (id < 1) ? 0 : id,
765                           on_table : 'core_email',
766                           successFn : successFn
767                       };
768                       
769                       
770                       Pman.Dialog.BAdminAutoSavePreview.show(params, function(res){
771                           _self.setValue(res);
772                           _self.originalValue = res;
773                       });
774                   }
775                 },
776                 xns : Roo.bootstrap,
777                 '|xns' : 'Roo.bootstrap',
778                 btns : [
779                  {
780                   xtype : 'Button',
781                   glyphicon : 'camera',
782                   html : _this._strings['7038eac66e387c3b3a0834d786a88757'] /* Insert Image */,
783                   toggle : false,
784                   listeners : {
785                    click : function (_self, e)
786                     {
787                         if (!_this.form.findField('bodytext').editorcore.activated) {
788                             Roo.bootstrap.MessageBox.alert('Cannot add any image', 'Please select a place in the belowing text area where the image will insert at');
789                             return;
790                         }
791                         
792                         var id = _this.form.findField('id').getValue();
793                         
794                         if(id*1 < 1){
795                             Roo.bootstrap.MessageBox.alert('Cannot add any image', 'Please save the email template first');
796                             return;
797                         }
798                         
799                         var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
800                         
801                         Pman.Dialog.BAdminImageManager.show({
802                             id: 0,
803                             onid: id,
804                             ontable: ontable
805                         }, function(img){
806                             _this.form.findField('bodytext').editorcore.insertAtCursor(
807                                 String.format(
808                                     '<img src="{0}/Images/{1}/{2}#image-{1}" height="{3}" width="{4}" alt="{5}" align="{6}">',
809                                     baseURL,
810                                     img.id,
811                                     img.filename.replace('%', '-'),
812                                     img.height,
813                                     img.width,
814                                     img.descript,
815                                     img.align
816                                 )
817                             )
818                         });
819                         
820                     }
821                   },
822                   xns : Roo.bootstrap,
823                   '|xns' : 'Roo.bootstrap'
824                  },
825                  {
826                   xtype : 'Button',
827                   glyphicon : 'tag',
828                   html : _this._strings['5feb9bf3c03b32635135006cbacb9542'] /* Insert Field */,
829                   toggle : false,
830                   xns : Roo.bootstrap,
831                   '|xns' : 'Roo.bootstrap',
832                   menu : {
833                    xtype : 'Menu',
834                    xns : Roo.bootstrap,
835                    '|xns' : 'Roo.bootstrap',
836                    items  : [
837                     {
838                      xtype : 'MenuItem',
839                      html : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
840                      listeners : {
841                       click : function (_self, e)
842                        {
843                            if (!_this.form.findField('bodytext').editorcore.activated) {
844                                Roo.bootstrap.MessageBox.alert('Cannot add the name tag', 'Please select a place in the belowing text area where the tag will insert at');
845                                return;
846                            }
847                            
848                            _this.form.findField('bodytext').editorcore.insertAtCursor(
849                                String.format('{0}',
850                                    '{person.name}'
851                                )
852                            );
853                        }
854                      },
855                      xns : Roo.bootstrap,
856                      '|xns' : 'Roo.bootstrap'
857                     },
858                     {
859                      xtype : 'MenuItem',
860                      html : _this._strings['4182c8f19d40c7ca236a5f4f83faeb6b'] /* Unsubscribe */,
861                      listeners : {
862                       click : function (_self, e)
863                        {
864                            if (!_this.form.findField('bodytext').editorcore.activated) {
865                                Roo.bootstrap.MessageBox.alert('Cannot add the unsubscribe tag', 'Please select a place in the belowing text area where the tag will insert at');
866                                return;
867                            }
868                            
869                            _this.form.findField('bodytext').editorcore.insertAtCursor(
870                                String.format('<a href="{0}">{1}</a>',
871                                    '#unsubscribe',  "Unsubscribe"
872                                )
873                            );
874                        }
875                      },
876                      xns : Roo.bootstrap,
877                      '|xns' : 'Roo.bootstrap'
878                     }
879                    ]
880                   }
881                  },
882                  {
883                   xtype : 'Button',
884                   glyphicon : 'refresh',
885                   html : _this._strings['b2bce8099bf8e6f51345bee5c9015c89'] /* Convert HTML to Plain Text */,
886                   toggle : false,
887                   listeners : {
888                    click : function (_self, e)
889                     {
890                         var h = _this.form.findField('bodytext').getValue();
891                         var p = _this.form.findField('plaintext');
892                         
893                         new Pman.Request({\r
894                             url : baseURL + '/Core/ImportMailMessage.php',\r
895                             method : 'POST',\r
896                             params : {
897                               bodytext : h,\r
898                               _convertToPlain : true,
899                               _check_unsubscribe : true\r
900                             }, \r
901                             success : function(res) {\r
902                                 if(res.success == true){
903                                    p.setValue(res.data);
904                                 }\r
905                             }\r
906                         });
907                         
908                     }
909                   },
910                   xns : Roo.bootstrap,
911                   '|xns' : 'Roo.bootstrap'
912                  },
913                  {
914                   xtype : 'Button',
915                   glyphicon : 'floppy-disk',
916                   html : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
917                   toggle : false,
918                   listeners : {
919                    click : function (_self, e)
920                     {
921                         this.scope.owner.fireEvent('savedpreview', this.scope.owner);
922                     }
923                   },
924                   xns : Roo.bootstrap,
925                   '|xns' : 'Roo.bootstrap'
926                  }
927                 ]
928                }
929               ]
930              }
931             ]
932            }
933           ]
934          },
935          {
936           xtype : 'Row',
937           listeners : {
938            click : function (_self, e)
939             {
940                 var h = _this.form.findField('bodytext').getValue();
941                 var p = _this.form.findField('plaintext');
942                 
943                 new Pman.Request({\r
944                     url : baseURL + '/Core/ImportMailMessage.php',\r
945                     method : 'POST',\r
946                     params : {
947                       bodytext : h,\r
948                       _convertToPlain : true,
949                       _check_unsubscribe : true\r
950                     }, \r
951                     success : function(res) {\r
952                         if(res.success == true){
953                            p.setValue(res.data);
954                         }\r
955                     }\r
956                 });
957                 
958             }
959           },
960           xns : Roo.bootstrap,
961           '|xns' : 'Roo.bootstrap',
962           items  : [
963            {
964             xtype : 'Column',
965             md : 12,
966             xns : Roo.bootstrap,
967             '|xns' : 'Roo.bootstrap',
968             items  : [
969              {
970               xtype : 'Container',
971               header : _this._strings['e44b145bd8b49b06e0ad2ced1ad56466'] /* Plain Text */,
972               panel : 'default',
973               xns : Roo.bootstrap,
974               '|xns' : 'Roo.bootstrap',
975               items  : [
976                {
977                 xtype : 'TextArea',
978                 name : 'plaintext',
979                 xns : Roo.bootstrap,
980                 '|xns' : 'Roo.bootstrap'
981                }
982               ]
983              }
984             ]
985            }
986           ]
987          },
988          {
989           xtype : 'Row',
990           xns : Roo.bootstrap,
991           '|xns' : 'Roo.bootstrap',
992           items  : [
993            {
994             xtype : 'Column',
995             md : 6,
996             xns : Roo.bootstrap,
997             '|xns' : 'Roo.bootstrap',
998             items  : [
999              {
1000               xtype : 'Input',
1001               allowBlank : false,
1002               disabled : true,
1003               fieldLabel : _this._strings['292f75d54a6892cfe18a93e64230112a'] /* Mailout Name: */,
1004               indicatorpos : 'right',
1005               labelAlign : 'top',
1006               name : 'name',
1007               xns : Roo.bootstrap,
1008               '|xns' : 'Roo.bootstrap'
1009              }
1010             ]
1011            },
1012            {
1013             xtype : 'Column',
1014             md : 6,
1015             xns : Roo.bootstrap,
1016             '|xns' : 'Roo.bootstrap',
1017             items  : [
1018              {
1019               xtype : 'Input',
1020               disabled : true,
1021               fieldLabel : _this._strings['3858712080cb3d846ea206d1d1070674'] /* Test Class (for system reference only): */,
1022               labelAlign : 'top',
1023               name : 'test_class',
1024               xns : Roo.bootstrap,
1025               '|xns' : 'Roo.bootstrap'
1026              }
1027             ]
1028            }
1029           ]
1030          },
1031          {
1032           xtype : 'Input',
1033           inputType : 'hidden',
1034           labelWidth : 3,
1035           name : 'id',
1036           xns : Roo.bootstrap,
1037           '|xns' : 'Roo.bootstrap'
1038          },
1039          {
1040           xtype : 'Input',
1041           inputType : 'hidden',
1042           labelWidth : 3,
1043           name : '_ignore_group_count',
1044           xns : Roo.bootstrap,
1045           '|xns' : 'Roo.bootstrap'
1046          }
1047         ]
1048        }
1049       ]
1050      }
1051     ]
1052    }  );
1053  }
1054 });
1055 Roo.apply(Pman.Dialog.BAdminEmail, Pman.Dialog.BAdminEmail.prototype);