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