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