Pman.Dialog.CoreEmail.bjs
[Pman.Core] / Pman.Dialog.CoreEmail.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.CoreEmail = {
8
9  _strings : {
10   '308f2757bfc9ce92fb00ff93fdffd279' :"Images / Attachments",
11   'dc0de523c25be298ba751c63c694109e' :"Responsive Email (1)",
12   'ea30b40c3caf28acb29198d20d243e54' :"Images / Attachments >>",
13   '4c2a8fe7eaf24721cc7a9f0175115bd4' :"Message",
14   '2f26e35d61be90501e099089dc533638' :"Select Images",
15   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
16   '72d6d7a1885885bb55a565fd1070581a' :"Import",
17   '884df8e413319ff51a3f5f528606238a' :"Use template",
18   '396ecabf0cd1f9503e591418851ef406' :"Edit / Create Message",
19   '31bb2f6e9b8fb11cbb7fb63c6025223f' :"Select Template",
20   '1bd18d39370b7f26c1c5e18067b74c6f' :"Html File",
21   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
22   'b78a3223503896721cca1303f776159b' :"Title",
23   '31fde7b05ac8952dacf4af8a704074ec' :"Preview",
24   '5b8ef4e762c00a15a41cfc26dc3ef99c' :"Send me a test copy",
25   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
26   '962b90039a542a29cedd51d87a9f28a1' :"Html Editor",
27   '5feb9bf3c03b32635135006cbacb9542' :"Insert Field",
28   '2393ad754ba179442d85e415d1d5167c' :"Displayorder",
29   'b9c49611cfda3259a2b837b39489e650' :"Add Image",
30   'e44b145bd8b49b06e0ad2ced1ad56466' :"Plain Text",
31   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
32   '1351017ac6423911223bc19a8cb7c653' :"Filename",
33   'c9cc8cce247e49bae79f15173ce97354' :"Save",
34   'e6b391a8d2c4d45902a23a8b6585703d' :"URL",
35   'e9968623956c15023d54335ea3699855' :"Convert Html to Text"
36  },
37
38  dialog : false,
39  callback:  false,
40
41  show : function(data, cb)
42  {
43   if (!this.dialog) {
44    this.create();
45   }
46
47   this.callback = cb;
48   this.data = data;
49   this.dialog.show(this.data._el);
50   if (this.form) {
51    this.form.reset();
52    this.form.setValues(data);
53    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
54   }
55
56  },
57
58  create : function()
59  {
60    var _this = this;
61    this.dialog = Roo.factory({
62     center : {
63      '|xns' : 'Roo',
64      tabPosition : 'top',
65      xns : Roo,
66      xtype : 'LayoutRegion'
67     },
68     east : {
69      '|xns' : 'Roo',
70      hidden : true,
71      split : true,
72      title : _this._strings['308f2757bfc9ce92fb00ff93fdffd279'],
73      titlebar : true,
74      width : 500,
75      xns : Roo,
76      xtype : 'LayoutRegion'
77     },
78     '|xns' : 'Roo',
79     closable : true,
80     collapsible : false,
81     height : 500,
82     modal : true,
83     resizable : true,
84     title : _this._strings['396ecabf0cd1f9503e591418851ef406'],
85     width : 800,
86     xns : Roo,
87     xtype : 'LayoutDialog',
88     buttons : [
89       {
90        '|xns' : 'Roo',
91        text : _this._strings['31fde7b05ac8952dacf4af8a704074ec'],
92        xns : Roo,
93        xtype : 'Button',
94        listeners : {
95         click : function (_self, e)
96          {
97              //_this.dialog.hide();
98              Roo.log(_this.data.module);
99              Pman.Dialog.CoreEmailPreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });
100          },
101         render : function (_self)
102          {
103              _this.preview_btn = _self;
104          }
105        }
106       },
107 {
108        '|xns' : 'Roo',
109        text : _this._strings['5b8ef4e762c00a15a41cfc26dc3ef99c'],
110        xns : Roo,
111        xtype : 'Button',
112        listeners : {
113         click : function (_self, e)
114          {
115              //_this.dialog.hide();
116              
117              var id = _this.form.findField('id').getValue();
118              
119              if(id*1 < 1){
120                  Roo.MessageBox.alert('Error', 'Please save the message frist!');
121                  return;
122              }
123             
124              new Pman.Request({
125                  url : baseURL + '/Core/MessagePreview',
126                  method : 'POST',
127                  mask: 'Sending',
128                  params : {
129                      _id : id,
130                      _table : _this.data.module
131                  }, 
132                  success : function(res) { 
133                      if(res.data == 'SUCCESS'){
134                          Roo.MessageBox.alert("Email Sent", 'The report was sent to your email (HTML format).');
135                      }
136                  }
137              });
138          },
139         render : function (_self)
140          {
141              _this.html_preview = _self;
142          }
143        }
144       },
145 {
146        '|xns' : 'Roo',
147        text : _this._strings['ea4788705e6873b424c65e91c2846b19'],
148        xns : Roo,
149        xtype : 'Button',
150        listeners : {
151         click : function (_self, e)
152          {
153              _this.dialog.hide();
154          }
155        }
156       },
157 {
158        '|xns' : 'Roo',
159        text : _this._strings['c9cc8cce247e49bae79f15173ce97354'],
160        xns : Roo,
161        xtype : 'Button',
162        listeners : {
163         click : function (_self, e)
164          {
165          
166              // do some checks?
167              _this.form.preValidate(function(res) {
168                  if (!res) {
169                      return; //failed.
170                  }
171                   _this.form.doAction("submit");
172              });
173          
174          }
175        }
176       }
177     ],
178     listeners : {
179      show : function (_self)
180       {
181           
182           _self.layout.getRegion('center').showPanel(0);
183           var w = Roo.lib.Dom.getViewWidth();\r
184           var h = Roo.lib.Dom.getViewHeight();    \r    this.resizeTo(w-50, h-50);\r
185           this.center();\r    
186           var ew = Math.max(250, w-320);\r
187           var eh = Math.max(250, h-350) ;\r
188           var e = _this.dialog.layout.getRegion('east');
189           if (e.visible) {
190               e.hide();
191           }
192           
193           var el = _self.getEl();
194           var elw = el.dom.clientWidth;
195           
196           var bdtext = _this.form.findField('bodytext');
197           var ptext = _this.form.findField('plaintext');
198           if(bdtext.resizeEl){
199               bdtext.width = elw-100;
200               bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height  ] );
201               ptext.setSize(bdtext.width , bdtext.height);
202           }
203           
204       }
205     },
206     items : [
207      {
208       toolbar : {
209        '|xns' : 'Roo',
210        xns : Roo,
211        xtype : 'Toolbar',
212        items : [
213         {
214          menu : {
215           '|xns' : 'Roo.menu',
216           xns : Roo.menu,
217           xtype : 'Menu',
218           items : [
219            {
220             '|xns' : 'Roo.menu',
221             text : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'],
222             xns : Roo.menu,
223             xtype : 'Item',
224             listeners : {
225              click : function (_self, e)
226               {
227                   Pman.Dialog.CoreImportUrl.show({
228                       target : '/Core/ImportMailMessage.php'
229                   }, function(data) {
230                       if  (data) {
231                         //  Roo.log(data);
232                           _this.form.findField('bodytext').setValue(data);
233                       }
234                   });
235               }
236             }
237            },
238            {
239             '|xns' : 'Roo.menu',
240             text : _this._strings['1bd18d39370b7f26c1c5e18067b74c6f'],
241             xns : Roo.menu,
242             xtype : 'Item',
243             listeners : {
244              click : function (_self, e)
245               {
246                   Pman.Dialog.Image.show({
247                       _url : baseURL + '/Core/ImportMailMessage.php'
248                   }, function(data) {
249                       if  (data) {
250                           _this.form.findField('bodytext').setValue(data);
251                       }
252                   });
253               }
254             }
255            }
256           ]
257
258          },
259          '|xns' : 'Roo.Toolbar',
260          text : _this._strings['72d6d7a1885885bb55a565fd1070581a'],
261          xns : Roo.Toolbar,
262          xtype : 'Button',
263          items : [
264
265          ]
266
267         },
268         {
269          menu : {
270           '|xns' : 'Roo.menu',
271           xns : Roo.menu,
272           xtype : 'Menu',
273           items : [
274            {
275             '|xns' : 'Roo.menu',
276             text : _this._strings['dc0de523c25be298ba751c63c694109e'],
277             xns : Roo.menu,
278             xtype : 'Item',
279             listeners : {
280              click : function (_self, e)
281               {
282               
283                   var l = document.location;
284                   new Pman.Request({
285               
286                       url : baseURL + '/Core/ImportMailMessage.php',
287               
288                       method: 'POST',
289                       mask : "Loading",
290                       params : {
291                             importUrl : l.protocol +'//' + l.host +   rootURL + '/Pman/Crm/mail_templates/responsive1.html',
292                      },
293                       success : function (res) {
294               
295                        _this.form.findField('bodytext').setValue(res.data);
296                       }
297                 
298                   });
299               }
300             }
301            }
302           ]
303
304          },
305          '|xns' : 'Roo.Toolbar',
306          text : _this._strings['884df8e413319ff51a3f5f528606238a'],
307          xns : Roo.Toolbar,
308          xtype : 'Button',
309          items : [
310
311          ]
312
313         },
314         {
315          store : {
316           proxy : {
317            '|xns' : 'Roo.data',
318            method : 'GET',
319            url : baseURL + '/Core/MailTemplateList.php',
320            xns : Roo.data,
321            xtype : 'HttpProxy'
322           },
323           reader : {
324            '|xns' : 'Roo.data',
325            fields : [{"name":"file","type":"string"},{"name":"content","type":"string"}],
326            id : 'name',
327            root : 'data',
328            totalProperty : 'total',
329            xns : Roo.data,
330            xtype : 'JsonReader'
331           },
332           '|xns' : 'Roo.data',
333           remoteSort : true,
334           sortInfo : { direction : 'DESC', field: 'file' },
335           xns : Roo.data,
336           xtype : 'Store',
337           listeners : {
338            beforeload : function (_self, o){
339                 o.params = o.params || {};
340                 // set more here
341                
342             }
343           },
344           items : [
345
346           ]
347
348          },
349          '|xns' : 'Roo.form',
350          allowBlank : true,
351          alwaysQuery : true,
352          displayField : 'file',
353          editable : false,
354          emptyText : _this._strings['31bb2f6e9b8fb11cbb7fb63c6025223f'],
355          fieldLabel : 'Template',
356          forceSelection : true,
357          hiddenName : 'template',
358          listWidth : 400,
359          loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'],
360          minChars : 2,
361          name : 'template',
362          pageSize : 20,
363          qtip : _this._strings['31bb2f6e9b8fb11cbb7fb63c6025223f'],
364          selectOnFocus : true,
365          tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{file}</b> </div>',
366          triggerAction : 'all',
367          typeAhead : true,
368          valueField : 'file',
369          width : 200,
370          xns : Roo.form,
371          xtype : 'ComboBox',
372          listeners : {
373           select : function (combo, record, index)
374            {
375               
376            /*
377                (function() { 
378                    combo.setValue('');
379                }).defer(100);
380            */    
381                if(!record){
382                    return;
383                }
384                _this.form.findField('bodytext').setValue(record.data.content);
385            
386            }
387          },
388          items : [
389
390          ]
391
392         },
393         {
394          '|xns' : 'Roo.Toolbar',
395          xns : Roo.Toolbar,
396          xtype : 'Fill'
397         },
398         {
399          '|xns' : 'Roo.Toolbar',
400          text : _this._strings['ea30b40c3caf28acb29198d20d243e54'],
401          xns : Roo.Toolbar,
402          xtype : 'Button',
403          listeners : {
404           click : function (_self, e)
405            {
406                var el = _this.dialog.layout.getRegion('east');
407                if (el.visible) {
408                    el.hide();
409                } else {
410                    el.show();
411                    el.showPanel(0);
412                }
413                
414            }
415          }
416         }
417        ]
418
419       },
420       layout : {
421        center : {
422         '|xns' : 'Roo',
423         autoScroll : true,
424         xns : Roo,
425         xtype : 'LayoutRegion'
426        },
427        '|xns' : 'Roo',
428        xns : Roo,
429        xtype : 'BorderLayout',
430        items : [
431         {
432          '|xns' : 'Roo',
433          autoScroll : false,
434          background : false,
435          fitContainer : true,
436          fitToFrame : true,
437          region : 'center',
438          title : _this._strings['4c2a8fe7eaf24721cc7a9f0175115bd4'],
439          xns : Roo,
440          xtype : 'ContentPanel',
441          listeners : {
442           render : function (_self, width, height)
443            {
444                
445                  Roo.log("RESIZE, " + width + ',' + height);
446                
447                var ew = Math.max(250, width-50);
448                var eh = Math.max(250,height-50) ;
449                
450               
451            
452            },
453           resize : function (_self, width, height)\r
454            {\r
455               var ew = Math.max(250, width-50);\r
456                var eh = Math.max(250,height-50) ;
457                
458                if (!_this.form) {\r
459                    return;\r
460                }\r
461                var bdtext = _this.form.findField('bodytext');\r
462                var ptext = _this.form.findField('plaintext');\r
463                if(bdtext.resizeEl){\r
464                    bdtext.width = ew-50;\r
465                    bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height  ] );\r
466                    ptext.setSize(bdtext.width , bdtext.height);\r
467                }\r\r
468            \r
469            }
470          },
471          items : [
472           {
473            '|xns' : 'Roo.form',
474            labelAlign : 'right',
475            labelWidth : 120,
476            method : 'POST',
477            preValidate : function(done_callback) {
478                
479                Roo.MessageBox.progress("Uploading Images", "Uploading");
480                var html = _this.form.findField('bodytext').getValue();
481                
482                var s = Roo.get(_this.form.findField('bodytext').editorcore.doc.documentElement);
483                
484                var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
485                
486                var nodes = [];
487                s.select('img[src]').each(function(i) {
488                    nodes.push(i.dom);
489                });
490                var total = nodes.length;
491                var mkimg = function() {
492                
493                    if (!nodes.length) {
494                          Roo.MessageBox.hide();
495                          _this.form.findField('bodytext').syncValue();
496                          done_callback(true);
497                       //    _this.form.doAction("submit");
498                          return;
499                    }
500                    var i = nodes.pop(); 
501                    
502                    var n = i.getAttribute('src').match(/(baseURL|server_baseurl)/);
503                    
504                    if(n){
505                        mkimg();
506                        return;
507                    }
508                    
509                    n = i.getAttribute('src').match(/^http(.*)/)
510                   
511                    if(!n ){
512                        mkimg();
513                        return;
514                    }
515                    
516                    new Pman.Request({
517                        url : baseURL + '/Roo/Images.php',
518                        method : 'POST',
519                        params : {
520                            onid : _this.form.findField('id').getValue(),
521                            ontable : ontable ,
522                            _remote_upload : i.src
523                        },
524                        success : function(res){
525                            if(res.success == true){      
526                                i.setAttribute('src', res.data);
527                                Roo.MessageBox.updateProgress( (total - nodes.length) / total , "Done " + (total - nodes.length) + '/' + total);
528                            }
529                            mkimg();
530                        }
531                    });
532                   
533                }
534                mkimg();
535            },
536            style : 'margin:10px',
537            url : baseURL + '/Roo/crm_mailing_list_message.php',
538            xns : Roo.form,
539            xtype : 'Form',
540            listeners : {
541             actioncomplete : function(_self,action)
542              {
543                 
544                  if (action.type == 'setdata') {
545                  
546                      _this.data.module = _this.data.module || 'crm_mailing_list_message';
547                      
548                      _this.form.url = baseURL + '/Roo/' + _this.data.module;
549                      
550                      _this.html_preview.hide();
551                      _this.preview_btn.hide();
552                          
553                      if(_this.data.id*1 > 0){
554                          _this.dialog.el.mask("Loading");
555                          this.load({ method: 'GET', params: { '_id' : _this.data.id }});
556                          _this.html_preview.show();
557                          _this.preview_btn.show();
558                          
559                      } else {
560                          _this.form.setValues({
561                              'from_name' : Pman.Login.authUser.name,
562                              'from_email' : Pman.Login.authUser.email
563                          });
564                      }
565                     return;
566                  }
567                  if (action.type == 'load') {
568                      _this.dialog.el.unmask();
569                      return;
570                  }
571                  if (action.type =='submit') {
572                  
573                      _this.dialog.el.unmask();
574                      _this.dialog.hide();
575                  
576                       if (_this.callback) {
577                          _this.callback.call(_this, action.result.data);
578                       }
579                       _this.form.reset();
580                       return;
581                  }
582              },
583             rendered : function (form)
584              {
585                  _this.form= form;
586              }
587            },
588            items : [
589             {
590              '|xns' : 'Roo.form',
591              xns : Roo.form,
592              xtype : 'Row',
593              items : [
594               {
595                '|xns' : 'Roo.form',
596                allowBlank : false,
597                fieldLabel : 'Mailout Name',
598                name : 'name',
599                width : 400,
600                xns : Roo.form,
601                xtype : 'TextField'
602               }
603              ]
604
605             },
606             {
607              '|xns' : 'Roo.form',
608              xns : Roo.form,
609              xtype : 'Row',
610              items : [
611               {
612                '|xns' : 'Roo.form',
613                allowBlank : false,
614                fieldLabel : 'From',
615                name : 'from_name',
616                width : 300,
617                xns : Roo.form,
618                xtype : 'TextField'
619               },
620               {
621                '|xns' : 'Roo.form',
622                allowBlank : false,
623                fieldLabel : 'Email address',
624                name : 'from_email',
625                width : 300,
626                xns : Roo.form,
627                xtype : 'TextField'
628               }
629              ]
630
631             },
632             {
633              '|xns' : 'Roo.form',
634              allowBlank : false,
635              fieldLabel : 'Subject',
636              name : 'subject',
637              width : 600,
638              xns : Roo.form,
639              xtype : 'TextField'
640             },
641             {
642              '|xns' : 'Roo.form',
643              hideLabels : true,
644              xns : Roo.form,
645              xtype : 'Row',
646              items : [
647               {
648                '|xns' : 'Roo.form',
649                hideLabels : true,
650                legend : _this._strings['962b90039a542a29cedd51d87a9f28a1'],
651                style : 'text-align:center;',
652                xns : Roo.form,
653                xtype : 'FieldSet',
654                items : [
655                 {
656                  '|xns' : 'Roo.form',
657                  clearUp : false,
658                  cwhite : [ 
659                      'margin',
660                      'padding',
661                      'text-align',
662                      'background',
663                      'height',
664                      'width',
665                      'background-color',
666                      'font-size',
667                      'line-height',
668                      'color',
669                      'outline',
670                      'text-decoration',
671                      'position',
672                      'clear',
673                      'overflow',
674                      'margin-top',
675                      'border-bottom',
676                      'top',
677                      'list-style',
678                      'margin-left',
679                      'border',
680                      'float' ,
681                      'margin-right',
682                      'padding-top',
683                      'min-height',
684                      'left',
685                      'padding-left',
686                      'font-weight',
687                      'font-family',
688                      'display',
689                      'margin-bottom',
690                      'padding-bottom',
691                      'vertical-align',
692                      'cursor',
693                      'z-index',
694                      'right',
695                   ],
696                  height : 250,
697                  name : 'bodytext',
698                  resizable : 's',
699                  xns : Roo.form,
700                  xtype : 'HtmlEditor',
701                  toolbars : [
702                    {
703                     '|xns' : 'Roo.form.HtmlEditor',
704                     xns : Roo.form.HtmlEditor,
705                     xtype : 'ToolbarContext'
706                    },
707 {
708                     '|xns' : 'Roo.form.HtmlEditor',
709                     xns : Roo.form.HtmlEditor,
710                     xtype : 'ToolbarStandard',
711                     btns : [
712                       {
713                        store : {
714                         proxy : {
715                          '|xns' : 'Roo.data',
716                          method : 'GET',
717                          url : baseURL + '/Roo/Images.php',
718                          xns : Roo.data,
719                          xtype : 'HttpProxy'
720                         },
721                         reader : {
722                          '|xns' : 'Roo.data',
723                          fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
724                          id : 'id',
725                          root : 'data',
726                          totalProperty : 'total',
727                          xns : Roo.data,
728                          xtype : 'JsonReader'
729                         },
730                         '|xns' : 'Roo.data',
731                         remoteSort : true,
732                         sortInfo : { direction : 'ASC', field: 'id' },
733                         xns : Roo.data,
734                         xtype : 'Store',
735                         listeners : {
736                          beforeload : function (_self, o){
737                               o.params = o.params || {};
738                           
739                               var id = _this.form.findField('id').getValue() * 1;    
740                               if (!id) {
741                                   Roo.MessageBox.alert("Error", "Save email template first");
742                                   return false;
743                               }
744                               o.params.onid = id
745                               o.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
746                               
747                              // o.params.imgtype = 'PressRelease';
748                               //o.params['query[imagesize]'] = '150x150';
749                               // set more here
750                           }
751                         },
752                         items : [
753
754                         ]
755
756                        },
757                        '|xns' : 'Roo.form',
758                        alwaysQuery : true,
759                        displayField : 'name',
760                        editable : false,
761                        emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'],
762                        fieldLabel : 'Images',
763                        forceSelection : true,
764                        listWidth : 400,
765                        loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'],
766                        minChars : 2,
767                        pageSize : 20,
768                        qtip : _this._strings['2f26e35d61be90501e099089dc533638'],
769                        selectOnFocus : true,
770                        tpl : '<div class=\"x-grid-cell-text x-btn button\"><img src=\"{public_baseURL}/Core/Images/Thumb/150x150/{id}.jpg\" height=\"150\" width=\"150\"><b>{filename}</b> </div>',
771                        triggerAction : 'all',
772                        typeAhead : true,
773                        valueField : 'id',
774                        width : 100,
775                        xns : Roo.form,
776                        xtype : 'ComboBox',
777                        listeners : {
778                         beforequery : function (combo, query, forceAll, cancel, e)
779                          {
780                              var id = _this.form.findField('id').getValue() * 1;    
781                              if (!id) {
782                                  Roo.MessageBox.alert("Error", "Save message first");
783                                  return false;
784                              }
785                          },
786                         render : function (_self)
787                          {
788                              _this.extendimgselect = _self;
789                          },
790                         select : function (combo, record, index)
791                          {
792                              Roo.log(record);
793                              (function() { 
794                                  combo.setValue('');
795                              }).defer(100);
796                              var editor = _this.form.findField('bodytext').editorcore;
797                              editor.insertAtCursor(
798                                      String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
799                                      baseURL,  record.data.id, record.data.filename
800                                      )
801                               );
802                          
803                              
804                           }
805                        },
806                        items : [
807
808                        ]
809
810                       },
811 {
812                        store : {
813                         '|xns' : 'Roo.data',
814                         data : [ 
815                             [ '{person.firstname}', "First Name"],
816                             [ '{person.lastname}' , "Last Name"],
817                             [ '{person.name}', "Full Name"],
818                             [ '#unsubscribe', "Unsubscribe"]
819                         ],
820                         fields : [  'type', 'name'],
821                         xns : Roo.data,
822                         xtype : 'SimpleStore'
823                        },
824                        '|xns' : 'Roo.form',
825                        alwaysQuery : true,
826                        displayField : 'name',
827                        editable : false,
828                        emptyText : _this._strings['5feb9bf3c03b32635135006cbacb9542'],
829                        fieldLabel : 'Field',
830                        forceSelection : true,
831                        listWidth : 400,
832                        loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'],
833                        minChars : 2,
834                        pageSize : 20,
835                        qtip : _this._strings['5feb9bf3c03b32635135006cbacb9542'],
836                        selectOnFocus : true,
837                        tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>',
838                        triggerAction : 'all',
839                        typeAhead : true,
840                        valueField : 'type',
841                        width : 100,
842                        xns : Roo.form,
843                        xtype : 'ComboBox',
844                        listeners : {
845                         render : function (_self)
846                          {
847                              _this.unsubscribeselect = _self;
848                          },
849                         select : function (combo, record, index)
850                          {
851                              Roo.log(record);
852                              (function() { 
853                                  combo.setValue('');
854                              }).defer(100);
855                              var editor = _this.form.findField('bodytext').editorcore;
856                              
857                              if(record.data.name == 'Unsubscribe'){
858                                  editor.insertAtCursor(
859                                      String.format('<a href="{0}">{1}</a>',
860                                          record.data.type,  record.data.name
861                                      )
862                                  );
863                                  return;     
864                              }
865                              
866                              editor.insertAtCursor(
867                                  String.format('{0}',
868                                      record.data.type
869                                  )
870                              );
871                              
872                           }
873                        },
874                        items : [
875
876                        ]
877
878                       }
879                     ],
880                     items : [
881
882                     ]
883
884                    }
885                  ],
886                  items : [
887
888                  ]
889
890                 }
891                ]
892
893               }
894              ]
895
896             },
897             {
898              '|xns' : 'Roo.form',
899              hideLabels : true,
900              xns : Roo.form,
901              xtype : 'Row',
902              items : [
903               {
904                '|xns' : 'Roo',
905                text : _this._strings['e9968623956c15023d54335ea3699855'],
906                xns : Roo,
907                xtype : 'Button',
908                listeners : {
909                 click : function (_self, e)
910                  {
911                      var h = _this.form.findField('bodytext').getValue();
912                      var p = _this.form.findField('plaintext');
913                      
914                      new Pman.Request({\r
915                          url : baseURL + '/Core/ImportMailMessage.php',\r
916                          method : 'POST',\r
917                          params : {
918                            bodytext : h,\r
919                            _convertToPlain : true,
920                            _check_unsubscribe : true\r
921                          }, \r
922                          success : function(res) {\r
923                              if(res.success == true){
924                                 p.setValue(res.data);
925                              }\r
926                          }\r
927                      });  
928                      
929                  }
930                }
931               }
932              ]
933
934             },
935             {
936              '|xns' : 'Roo.form',
937              hideLabels : true,
938              xns : Roo.form,
939              xtype : 'Row',
940              items : [
941               {
942                '|xns' : 'Roo.form',
943                hideLabels : true,
944                legend : _this._strings['e44b145bd8b49b06e0ad2ced1ad56466'],
945                style : 'text-align:center;',
946                xns : Roo.form,
947                xtype : 'FieldSet',
948                items : [
949                 {
950                  '|xns' : 'Roo.form',
951                  height : 50,
952                  name : 'plaintext',
953                  xns : Roo.form,
954                  xtype : 'TextArea'
955                 }
956                ]
957
958               }
959              ]
960
961             },
962             {
963              '|xns' : 'Roo.form',
964              name : 'id',
965              xns : Roo.form,
966              xtype : 'Hidden'
967             }
968            ]
969
970           }
971          ]
972
973         }
974        ]
975
976       },
977       '|xns' : 'Roo',
978       autoScroll : false,
979       fitContainer : true,
980       fitToFrame : true,
981       region : 'center',
982       xns : Roo,
983       xtype : 'NestedLayoutPanel',
984       items : [
985
986       ]
987
988      },
989      {
990       grid : {
991        dataSource : {
992         proxy : {
993          '|xns' : 'Roo.data',
994          method : 'GET',
995          url : baseURL + '/Roo/Images.php',
996          xns : Roo.data,
997          xtype : 'HttpProxy'
998         },
999         reader : {
1000          '|xns' : 'Roo.data',
1001          fields : [
1002              {
1003                  'name': 'id',
1004                  'type': 'int'
1005              },
1006              {
1007                  'name': 'filename',
1008                  'type': 'string'
1009              },
1010              {
1011                  'name': 'ontable',
1012                  'type': 'string'
1013              },
1014              {
1015                  'name': 'onid',
1016                  'type': 'int'
1017              },
1018              {
1019                  'name': 'mimetype',
1020                  'type': 'string'
1021              },
1022              {
1023                  'name': 'width',
1024                  'type': 'int'
1025              },
1026              {
1027                  'name': 'height',
1028                  'type': 'int'
1029              },
1030              {
1031                  'name': 'filesize',
1032                  'type': 'int'
1033              },
1034              {
1035                  'name': 'displayorder',
1036                  'type': 'int'
1037              },
1038              {
1039                  'name': 'language',
1040                  'type': 'string'
1041              },
1042              {
1043                  'name': 'parent_image_id',
1044                  'type': 'int'
1045              },
1046              {
1047                  'name': 'created',
1048                  'type': 'date',
1049                  'dateFormat': 'Y-m-d'
1050              },
1051              {
1052                  'name': 'imgtype',
1053                  'type': 'string'
1054              },
1055              {
1056                  'name': 'linkurl',
1057                  'type': 'string'
1058              },
1059              {
1060                  'name': 'descript',
1061                  'type': 'string'
1062              },
1063              {
1064                  'name': 'title',
1065                  'type': 'string'
1066              },
1067              {
1068                  'name': 'parent_image_id_id',
1069                  'type': 'int'
1070              },
1071              {
1072                  'name': 'parent_image_id_filename',
1073                  'type': 'string'
1074              },
1075              {
1076                  'name': 'parent_image_id_ontable',
1077                  'type': 'string'
1078              },
1079              {
1080                  'name': 'parent_image_id_onid',
1081                  'type': 'int'
1082              },
1083              {
1084                  'name': 'parent_image_id_mimetype',
1085                  'type': 'string'
1086              },
1087              {
1088                  'name': 'parent_image_id_width',
1089                  'type': 'int'
1090              },
1091              {
1092                  'name': 'parent_image_id_height',
1093                  'type': 'int'
1094              },
1095              {
1096                  'name': 'parent_image_id_filesize',
1097                  'type': 'int'
1098              },
1099              {
1100                  'name': 'parent_image_id_displayorder',
1101                  'type': 'int'
1102              },
1103              {
1104                  'name': 'parent_image_id_language',
1105                  'type': 'string'
1106              },
1107              {
1108                  'name': 'parent_image_id_parent_image_id',
1109                  'type': 'int'
1110              },
1111              {
1112                  'name': 'parent_image_id_created',
1113                  'type': 'date'
1114              },
1115              {
1116                  'name': 'parent_image_id_imgtype',
1117                  'type': 'string'
1118              },
1119              {
1120                  'name': 'parent_image_id_linkurl',
1121                  'type': 'string'
1122              },
1123              {
1124                  'name': 'parent_image_id_descript',
1125                  'type': 'string'
1126              },
1127              {
1128                  'name': 'parent_image_id_title',
1129                  'type': 'string'
1130              }
1131          ],
1132          id : 'id',
1133          root : 'data',
1134          totalProperty : 'total',
1135          xns : Roo.data,
1136          xtype : 'JsonReader'
1137         },
1138         '|xns' : 'Roo.data',
1139         remoteSort : true,
1140         sortInfo : { field : 'filename', direction: 'ASC' },
1141         xns : Roo.data,
1142         xtype : 'Store',
1143         listeners : {
1144          beforeload : function (_self, options)
1145           {
1146               options.params = options.params || {};
1147               if (typeof(_this.data) == 'undefined') {
1148                   return false;
1149               }
1150               if(_this.data.id * 1 >= 0)
1151               {
1152                   options.params.onid = _this.data.id;
1153           
1154                   options.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
1155               }
1156           }
1157         },
1158         items : [
1159
1160         ]
1161
1162        },
1163        toolbar : {
1164         '|xns' : 'Roo',
1165         xns : Roo,
1166         xtype : 'Toolbar',
1167         items : [
1168          {
1169           '|xns' : 'Roo.Toolbar',
1170           cls : 'x-btn-text-icon',
1171           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
1172           text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'],
1173           xns : Roo.Toolbar,
1174           xtype : 'Button',
1175           listeners : {
1176            click : function()
1177             {
1178                 var id = _this.form.findField('id').getValue();
1179                 
1180                 if(id*1 < 1){
1181                     Roo.MessageBox.alert('Error', 'Please save the email template first');
1182                     return;
1183                 }
1184                 
1185                 var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
1186                 
1187                 Pman.Dialog.Image.show( { id : 0, onid: id, ontable: ontable }, function() {
1188                     _this.igrid.getDataSource().load({});
1189                 }); 
1190             }
1191           }
1192          },
1193          {
1194           '|xns' : 'Roo.Toolbar',
1195           cls : 'x-btn-text-icon',
1196           icon : rootURL + '/Pman/templates/images/trash.gif',
1197           text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'],
1198           xns : Roo.Toolbar,
1199           xtype : 'Button',
1200           listeners : {
1201            click : function()
1202             {
1203                 var s = _this.igrid.getSelectionModel().getSelected();
1204                 if (!s || isNaN(s.id *1)) {
1205                     Roo.MessageBox.alert("Error", "Select a image"); 
1206                     return;
1207                 }
1208                 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
1209                     if (v != 'yes') {
1210                         return;
1211                     }
1212                     
1213                     new Pman.Request({
1214                         url : baseURL + '/Roo/Images.php',
1215                         method: 'POST',
1216                         params : {
1217                             _delete : s.id
1218                         },
1219                         success : function()
1220                         {
1221                             Roo.log('Got Success!!');
1222                            _this.igrid.ds.load({});
1223                         }
1224                     });
1225                 });
1226             }
1227           }
1228          }
1229         ]
1230
1231        },
1232        '|xns' : 'Roo.grid',
1233        autoExpandColumn : 'filename',
1234        loadMask : true,
1235        xns : Roo.grid,
1236        xtype : 'Grid',
1237        colModel : [
1238          {
1239           '|xns' : 'Roo.grid',
1240           dataIndex : 'filename',
1241           header : _this._strings['1351017ac6423911223bc19a8cb7c653'],
1242           renderer : function(v,x,r)
1243           {
1244              return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + r.data.width + '" height="' + r.data.height + '" />';
1245           },
1246           width : 300,
1247           xns : Roo.grid,
1248           xtype : 'ColumnModel'
1249          },
1250 {
1251           '|xns' : 'Roo.grid',
1252           dataIndex : 'displayorder',
1253           header : _this._strings['2393ad754ba179442d85e415d1d5167c'],
1254           renderer : function(v) { return String.format('{0}', v); },
1255           width : 75,
1256           xns : Roo.grid,
1257           xtype : 'ColumnModel'
1258          },
1259 {
1260           '|xns' : 'Roo.grid',
1261           dataIndex : 'title',
1262           header : _this._strings['b78a3223503896721cca1303f776159b'],
1263           renderer : function(v) { return String.format('{0}', v); },
1264           width : 75,
1265           xns : Roo.grid,
1266           xtype : 'ColumnModel'
1267          }
1268        ],
1269        listeners : {
1270         render : function() 
1271          {
1272              _this.igrid = this; 
1273              //_this.dialog = Pman.Dialog.FILL_IN
1274              if (_this.ipanel.active) {
1275             //    _this.igrid.ds.load({});
1276              }
1277          }
1278        },
1279        items : [
1280
1281        ]
1282
1283       },
1284       '|xns' : 'Roo',
1285       autoScroll : false,
1286       background : false,
1287       fitContainer : true,
1288       fitToframe : true,
1289       region : 'east',
1290       tableName : 'Images',
1291       title : _this._strings['308f2757bfc9ce92fb00ff93fdffd279'],
1292       xns : Roo,
1293       xtype : 'GridPanel',
1294       listeners : {
1295        activate : function() {
1296             _this.ipanel = this;
1297             if (_this.igrid) {
1298                _this.igrid.ds.load({});
1299             }
1300         }
1301       },
1302       items : [
1303
1304       ]
1305
1306      }
1307     ]
1308
1309    });
1310  }
1311 };