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                                      if(ret == 'no'){
376                                          return;
377                                      }
378                                       
379                                      _this.form.findField('_ignore_group_count').setValue('1');
380                                      _this.form.doAction("submit");                       
381                                  }
382                              });
383                             /* Roo.bootstrap.MessageBox.confirm('Confirm Save', 'No member found in To Group: ' + _this.combo_to_group.getRawValue() ,function(ret) {
384                                  if(ret == 'no'){
385                                      return;
386                                  }
387                                   
388                                  _this.form.findField('_ignore_group_count').setValue('1');
389                                  _this.form.doAction("submit");                       
390                                  
391                              }, this);*/
392                              
393                          break;
394                          
395                          default:
396                              displayErr();
397                              break;
398                      }
399                      return;
400                  }
401                  displayErr();
402                  
403                  break;
404               case Roo.form.Action.CLIENT_INVALID: //for validation
405                  break;
406               case Roo.form.Action.CONNECT_FAILURE:
407                  Roo.bootstrap.MessageBox.alert("Connect Error", action.result.errorMsg);
408                  break;
409               default: 
410                  Roo.bootstrap.MessageBox.alert("Error", action.result.errorMsg);
411                  break;
412                  
413               }
414           },
415          render : function (_self)
416           {
417               _this.form = this;
418           }
419         },
420         xns : Roo.bootstrap,
421         '|xns' : 'Roo.bootstrap',
422         items  : [
423          {
424           xtype : 'Row',
425           xns : Roo.bootstrap,
426           '|xns' : 'Roo.bootstrap',
427           items  : [
428            {
429             xtype : 'Column',
430             md : 8,
431             xs : 12,
432             xns : Roo.bootstrap,
433             '|xns' : 'Roo.bootstrap',
434             items  : [
435              {
436               xtype : 'Input',
437               allowBlank : false,
438               fieldLabel : _this._strings['292f75d54a6892cfe18a93e64230112a'] /* Mailout Name: */,
439               indicatorpos : 'right',
440               labelWidth : 3,
441               name : 'name',
442               xns : Roo.bootstrap,
443               '|xns' : 'Roo.bootstrap'
444              }
445             ]
446            },
447            {
448             xtype : 'Column',
449             md : 4,
450             xns : Roo.bootstrap,
451             '|xns' : 'Roo.bootstrap',
452             items  : [
453              {
454               xtype : 'CheckBox',
455               boxLabel : _this._strings['28690be026c0bb9003aa58e45e5662ca'] /* Enabled - will be sent out */,
456               checked : true,
457               indicatorpos : 'right',
458               name : 'active',
459               value : 1,
460               valueOff : 0,
461               listeners : {
462                check : function (_self, checked)
463                 {
464                     var boxLabel = 'Enabled - will be sent out';
465                     
466                     if(!checked){
467                         boxLabel = 'Disabled - will NOT be sent out';
468                     }
469                     
470                     //this.setBoxLabel(boxLabel);
471                 }
472               },
473               xns : Roo.bootstrap,
474               '|xns' : 'Roo.bootstrap'
475              }
476             ]
477            }
478           ]
479          },
480          {
481           xtype : 'Row',
482           xns : Roo.bootstrap,
483           '|xns' : 'Roo.bootstrap',
484           items  : [
485            {
486             xtype : 'Column',
487             md : 6,
488             name : 'from_name',
489             xs : 12,
490             xns : Roo.bootstrap,
491             '|xns' : 'Roo.bootstrap',
492             items  : [
493              {
494               xtype : 'Input',
495               allowBlank : false,
496               fieldLabel : _this._strings['1e6d57e813355689e9c77e947d73ad8f'] /* From: */,
497               indicatorpos : 'right',
498               labelWidth : 4,
499               name : 'from_name',
500               xns : Roo.bootstrap,
501               '|xns' : 'Roo.bootstrap'
502              }
503             ]
504            },
505            {
506             xtype : 'Column',
507             md : 6,
508             xs : 12,
509             xns : Roo.bootstrap,
510             '|xns' : 'Roo.bootstrap',
511             items  : [
512              {
513               xtype : 'Input',
514               allowBlank : false,
515               fieldLabel : _this._strings['e71c729cd7f3c6b6ebdb447e65952dfd'] /* From email address: */,
516               indicatorpos : 'right',
517               labelWidth : 4,
518               name : 'from_email',
519               vtype : 'email',
520               xns : Roo.bootstrap,
521               '|xns' : 'Roo.bootstrap'
522              }
523             ]
524            }
525           ]
526          },
527          {
528           xtype : 'Row',
529           xns : Roo.bootstrap,
530           '|xns' : 'Roo.bootstrap',
531           items  : [
532            {
533             xtype : 'Column',
534             md : 6,
535             xs : 12,
536             listeners : {
537              render : function (_self)
538               {
539                   _this.to_group_row = this;
540               }
541             },
542             xns : Roo.bootstrap,
543             '|xns' : 'Roo.bootstrap',
544             items  : [
545              {
546               xtype : 'ComboBox',
547               allowBlank : true,
548               alwaysQuery : true,
549               displayField : 'name',
550               editable : false,
551               fieldLabel : _this._strings['fb981fe689fbec75c6531eb7410971f4'] /* To group: */,
552               forceSelection : true,
553               hiddenName : 'to_group_id',
554               indicatorpos : 'right',
555               labelAlign : 'left',
556               labelWidth : 4,
557               loadingText : _this._strings['843627586c62e389041a4d8800143974'] /* Searching */,
558               minChars : 2,
559               name : 'to_group_id_name',
560               pageSize : 20,
561               placeholder : _this._strings['e05f77bdf3f659c1fd354a88526c03da'] /* Select Group */,
562               triggerAction : 'all',
563               typeAhead : true,
564               valueField : 'id',
565               listeners : {
566                render : function (_self)
567                 {
568                     _this.combo_to_group = _self;
569                 }
570               },
571               xns : Roo.bootstrap,
572               '|xns' : 'Roo.bootstrap',
573               store : {
574                xtype : 'Store',
575                remoteSort : true,
576                sortInfo : { direction : 'ASC', field: 'name' },
577                listeners : {
578                 beforeload : function (_self, o){
579                      o.params = o.params || {};
580                      
581                      o.params._direct_return = 1;
582                  }
583                },
584                xns : Roo.data,
585                '|xns' : 'Roo.data',
586                proxy : {
587                 xtype : 'HttpProxy',
588                 method : 'GET',
589                 url : baseURL + '/Roo/Core_group',
590                 xns : Roo.data,
591                 '|xns' : 'Roo.data'
592                },
593                reader : {
594                 xtype : 'JsonReader',
595                 fields : [{"name":"name","type":"string"},{"name":"id","type":"int"}],
596                 id : 'name',
597                 root : 'data',
598                 totalProperty : 'total',
599                 xns : Roo.data,
600                 '|xns' : 'Roo.data'
601                }
602               }
603              }
604             ]
605            },
606            {
607             xtype : 'Column',
608             md : 6,
609             xs : 12,
610             xns : Roo.bootstrap,
611             '|xns' : 'Roo.bootstrap',
612             items  : [
613              {
614               xtype : 'ComboBox',
615               allowBlank : true,
616               alwaysQuery : true,
617               displayField : 'name',
618               editable : false,
619               fieldLabel : _this._strings['edddfc18b2ffb806573a1b3f341832cd'] /* BCC to Group: */,
620               forceSelection : true,
621               hiddenName : 'bcc_group_id',
622               indicatorpos : 'right',
623               labelAlign : 'left',
624               labelWidth : 4,
625               loadingText : _this._strings['843627586c62e389041a4d8800143974'] /* Searching */,
626               minChars : 2,
627               name : 'bcc_group_id_name',
628               pageSize : 20,
629               placeholder : _this._strings['2c466a2c159463f1d9ef5a7b57b52827'] /* Select BCC Group */,
630               triggerAction : 'all',
631               typeAhead : true,
632               valueField : 'id',
633               xns : Roo.bootstrap,
634               '|xns' : 'Roo.bootstrap',
635               store : {
636                xtype : 'Store',
637                remoteSort : true,
638                sortInfo : { direction : 'ASC', field: 'name' },
639                listeners : {
640                 beforeload : function (_self, o){
641                      o.params = o.params || {};
642                      
643                      o.params._direct_return = 1;
644                  }
645                },
646                xns : Roo.data,
647                '|xns' : 'Roo.data',
648                proxy : {
649                 xtype : 'HttpProxy',
650                 method : 'GET',
651                 url : baseURL + '/Roo/Core_group',
652                 xns : Roo.data,
653                 '|xns' : 'Roo.data'
654                },
655                reader : {
656                 xtype : 'JsonReader',
657                 fields : [{"name":"name","type":"string"},{"name":"id","type":"int"}],
658                 id : 'name',
659                 root : 'data',
660                 totalProperty : 'total',
661                 xns : Roo.data,
662                 '|xns' : 'Roo.data'
663                }
664               }
665              }
666             ]
667            }
668           ]
669          },
670          {
671           xtype : 'Row',
672           xns : Roo.bootstrap,
673           '|xns' : 'Roo.bootstrap',
674           items  : [
675            {
676             xtype : 'Column',
677             md : 12,
678             xs : 12,
679             xns : Roo.bootstrap,
680             '|xns' : 'Roo.bootstrap',
681             items  : [
682              {
683               xtype : 'Input',
684               allowBlank : false,
685               fieldLabel : _this._strings['47a0be8d1015d526a1fbaa56c3102135'] /* Subject: */,
686               indicatorpos : 'right',
687               labelWidth : 2,
688               name : 'subject',
689               xns : Roo.bootstrap,
690               '|xns' : 'Roo.bootstrap'
691              }
692             ]
693            }
694           ]
695          },
696          {
697           xtype : 'Row',
698           xns : Roo.bootstrap,
699           '|xns' : 'Roo.bootstrap',
700           items  : [
701            {
702             xtype : 'Column',
703             md : 12,
704             xns : Roo.bootstrap,
705             '|xns' : 'Roo.bootstrap',
706             items  : [
707              {
708               xtype : 'Container',
709               header : _this._strings['36a65bbd12f7586ea1f9b0be4e8848aa'] /* HTML Editor */,
710               panel : 'default',
711               xns : Roo.bootstrap,
712               '|xns' : 'Roo.bootstrap',
713               items  : [
714                {
715                 xtype : 'HtmlEditor',
716                 bodyCls : 'roo-email',
717                 name : 'bodytext',
718                 stylesheets : '',
719                 listeners : {
720                  autosave : function (_self)
721                   {
722                       Roo.log('autosave');
723                       
724                       var id = _this.form.findField('id').getValue() * 1;
725                       
726                       new Pman.Request({
727                           url : baseURL + '/Roo/Events.php',
728                           method :'POST',
729                           params : {
730                               id : 0,
731                               action : 'AUTOSAVE',
732                               on_id : (id > 0) ? id : 0,
733                               on_table : 'crm_mailing_list_message',
734                               remarks : 'BODY',
735                               source: _self.getValue()
736                           },
737                           success : function() {
738                               _self.originalValue = _self.getValue();
739                               
740                           },
741                           failure : function() 
742                           {
743                               Roo.log('body autosave failed?!');
744                           }
745                       });
746                       
747                   },
748                  render : function (_self)
749                   {
750                       _this.htmleditor = this;
751                   },
752                  savedpreview : function (_self)
753                   {
754                       var id = _this.form.findField('id').getValue() * 1;
755                       
756                       var successFn = function(res){
757                           return res.data.POST.source;
758                       };
759                       
760                       var params = {
761                           action : 'AUTOSAVE',
762                           remarks : 'BODY',
763                           on_id : (id < 1) ? 0 : id,
764                           on_table : 'core_email',
765                           successFn : successFn
766                       };
767                       
768                       
769                       Pman.Dialog.BAdminAutoSavePreview.show(params, function(res){
770                           _self.setValue(res);
771                           _self.originalValue = res;
772                       });
773                   }
774                 },
775                 xns : Roo.bootstrap,
776                 '|xns' : 'Roo.bootstrap',
777                 btns : [
778                  {
779                   xtype : 'Button',
780                   glyphicon : 'camera',
781                   html : _this._strings['7038eac66e387c3b3a0834d786a88757'] /* Insert Image */,
782                   toggle : false,
783                   listeners : {
784                    click : function (_self, e)
785                     {
786                         if (!_this.form.findField('bodytext').editorcore.activated) {
787                             Roo.bootstrap.MessageBox.alert('Cannot add any image', 'Please select a place in the belowing text area where the image will insert at');
788                             return;
789                         }
790                         
791                         var id = _this.form.findField('id').getValue();
792                         
793                         if(id*1 < 1){
794                             Roo.bootstrap.MessageBox.alert('Cannot add any image', 'Please save the email template first');
795                             return;
796                         }
797                         
798                         var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
799                         
800                         Pman.Dialog.BAdminImageManager.show({
801                             id : 0,
802                             onid: id,
803                             ontable: ontable
804                         });
805                         
806                     }
807                   },
808                   xns : Roo.bootstrap,
809                   '|xns' : 'Roo.bootstrap'
810                  },
811                  {
812                   xtype : 'Button',
813                   glyphicon : 'tag',
814                   html : _this._strings['5feb9bf3c03b32635135006cbacb9542'] /* Insert Field */,
815                   toggle : false,
816                   xns : Roo.bootstrap,
817                   '|xns' : 'Roo.bootstrap',
818                   menu : {
819                    xtype : 'Menu',
820                    xns : Roo.bootstrap,
821                    '|xns' : 'Roo.bootstrap',
822                    items  : [
823                     {
824                      xtype : 'MenuItem',
825                      html : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
826                      listeners : {
827                       click : function (_self, e)
828                        {
829                            if (!_this.form.findField('bodytext').editorcore.activated) {
830                                Roo.bootstrap.MessageBox.alert('Cannot add the name tag', 'Please select a place in the belowing text area where the tag will insert at');
831                                return;
832                            }
833                            
834                            _this.form.findField('bodytext').editorcore.insertAtCursor(
835                                String.format('{0}',
836                                    '{person.name}'
837                                )
838                            );
839                        }
840                      },
841                      xns : Roo.bootstrap,
842                      '|xns' : 'Roo.bootstrap'
843                     },
844                     {
845                      xtype : 'MenuItem',
846                      html : _this._strings['4182c8f19d40c7ca236a5f4f83faeb6b'] /* Unsubscribe */,
847                      listeners : {
848                       click : function (_self, e)
849                        {
850                            if (!_this.form.findField('bodytext').editorcore.activated) {
851                                Roo.bootstrap.MessageBox.alert('Cannot add the unsubscribe tag', 'Please select a place in the belowing text area where the tag will insert at');
852                                return;
853                            }
854                            
855                            _this.form.findField('bodytext').editorcore.insertAtCursor(
856                                String.format('<a href="{0}">{1}</a>',
857                                    '#unsubscribe',  "Unsubscribe"
858                                )
859                            );
860                        }
861                      },
862                      xns : Roo.bootstrap,
863                      '|xns' : 'Roo.bootstrap'
864                     }
865                    ]
866                   }
867                  },
868                  {
869                   xtype : 'Button',
870                   glyphicon : 'refresh',
871                   html : _this._strings['b2bce8099bf8e6f51345bee5c9015c89'] /* Convert HTML to Plain Text */,
872                   toggle : false,
873                   listeners : {
874                    click : function (_self, e)
875                     {
876                         var h = _this.form.findField('bodytext').getValue();
877                         var p = _this.form.findField('plaintext');
878                         
879                         new Pman.Request({\r
880                             url : baseURL + '/Core/ImportMailMessage.php',\r
881                             method : 'POST',\r
882                             params : {
883                               bodytext : h,\r
884                               _convertToPlain : true,
885                               _check_unsubscribe : true\r
886                             }, \r
887                             success : function(res) {\r
888                                 if(res.success == true){
889                                    p.setValue(res.data);
890                                 }\r
891                             }\r
892                         });
893                         
894                     }
895                   },
896                   xns : Roo.bootstrap,
897                   '|xns' : 'Roo.bootstrap'
898                  },
899                  {
900                   xtype : 'Button',
901                   glyphicon : 'floppy-disk',
902                   html : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
903                   toggle : false,
904                   listeners : {
905                    click : function (_self, e)
906                     {
907                         this.scope.owner.fireEvent('savedpreview', this.scope.owner);
908                     }
909                   },
910                   xns : Roo.bootstrap,
911                   '|xns' : 'Roo.bootstrap'
912                  }
913                 ]
914                }
915               ]
916              }
917             ]
918            }
919           ]
920          },
921          {
922           xtype : 'Row',
923           listeners : {
924            click : function (_self, e)
925             {
926                 var h = _this.form.findField('bodytext').getValue();
927                 var p = _this.form.findField('plaintext');
928                 
929                 new Pman.Request({\r
930                     url : baseURL + '/Core/ImportMailMessage.php',\r
931                     method : 'POST',\r
932                     params : {
933                       bodytext : h,\r
934                       _convertToPlain : true,
935                       _check_unsubscribe : true\r
936                     }, \r
937                     success : function(res) {\r
938                         if(res.success == true){
939                            p.setValue(res.data);
940                         }\r
941                     }\r
942                 });
943                 
944             }
945           },
946           xns : Roo.bootstrap,
947           '|xns' : 'Roo.bootstrap',
948           items  : [
949            {
950             xtype : 'Column',
951             md : 12,
952             xns : Roo.bootstrap,
953             '|xns' : 'Roo.bootstrap',
954             items  : [
955              {
956               xtype : 'Container',
957               header : _this._strings['e44b145bd8b49b06e0ad2ced1ad56466'] /* Plain Text */,
958               panel : 'default',
959               xns : Roo.bootstrap,
960               '|xns' : 'Roo.bootstrap',
961               items  : [
962                {
963                 xtype : 'TextArea',
964                 name : 'plaintext',
965                 xns : Roo.bootstrap,
966                 '|xns' : 'Roo.bootstrap'
967                }
968               ]
969              }
970             ]
971            }
972           ]
973          },
974          {
975           xtype : 'Row',
976           xns : Roo.bootstrap,
977           '|xns' : 'Roo.bootstrap',
978           items  : [
979            {
980             xtype : 'Column',
981             md : 12,
982             xns : Roo.bootstrap,
983             '|xns' : 'Roo.bootstrap',
984             items  : [
985              {
986               xtype : 'Input',
987               fieldLabel : _this._strings['3858712080cb3d846ea206d1d1070674'] /* Test Class (for system reference only): */,
988               labelAlign : 'top',
989               name : 'test_class',
990               xns : Roo.bootstrap,
991               '|xns' : 'Roo.bootstrap'
992              }
993             ]
994            }
995           ]
996          },
997          {
998           xtype : 'Input',
999           inputType : 'hidden',
1000           labelWidth : 3,
1001           name : 'id',
1002           xns : Roo.bootstrap,
1003           '|xns' : 'Roo.bootstrap'
1004          },
1005          {
1006           xtype : 'Input',
1007           inputType : 'hidden',
1008           labelWidth : 3,
1009           name : '_ignore_group_count',
1010           xns : Roo.bootstrap,
1011           '|xns' : 'Roo.bootstrap'
1012          }
1013         ]
1014        }
1015       ]
1016      }
1017     ]
1018    }  );
1019  }
1020 });
1021 Roo.apply(Pman.Dialog.BAdminEmail, Pman.Dialog.BAdminEmail.prototype);