Pman.Dialog.CoreEmail.bjs
[Pman.Core] / Pman.Dialog.CoreEmail.bjs
1 {
2  "name" : "Pman.Dialog.CoreEmail",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/edward/gitlive/Pman.Core/Pman.Dialog.CoreEmail.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "e44b145bd8b49b06e0ad2ced1ad56466" : "Plain Text",
10   "2f26e35d61be90501e099089dc533638" : "Select Images",
11   "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
12   "b357b524e740bc85b9790a0712d84a30" : "Email address",
13   "962b90039a542a29cedd51d87a9f28a1" : "Html Editor",
14   "72d6d7a1885885bb55a565fd1070581a" : "Import",
15   "ea30b40c3caf28acb29198d20d243e54" : "Images / Attachments >>",
16   "31fde7b05ac8952dacf4af8a704074ec" : "Preview",
17   "884df8e413319ff51a3f5f528606238a" : "Use template",
18   "e6b391a8d2c4d45902a23a8b6585703d" : "URL",
19   "2393ad754ba179442d85e415d1d5167c" : "Displayorder",
20   "6f16a5f8ff5d75ab84c018adacdfcbb7" : "Field",
21   "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
22   "e9968623956c15023d54335ea3699855" : "Convert Html to Text",
23   "1243daf593fa297e07ab03bf06d925af" : "Searching...",
24   "5b8ef4e762c00a15a41cfc26dc3ef99c" : "Send me a test copy",
25   "c7892ebbb139886662c6f2fc8c450710" : "Subject",
26   "dc0de523c25be298ba751c63c694109e" : "Responsive Email (1)",
27   "396ecabf0cd1f9503e591418851ef406" : "Edit / Create Message",
28   "b9c49611cfda3259a2b837b39489e650" : "Add Image",
29   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
30   "68b00d723d37122f64da8d9939f836f0" : "BCC Group",
31   "c4ca4238a0b923820dcc509a6f75849b" : "1",
32   "bd88a20b53a47f7b5704a83a15ff5506" : "Saved Version",
33   "b20a8b77b05d53b4e695738731400c85" : "Mailout Name",
34   "1bd18d39370b7f26c1c5e18067b74c6f" : "Html File",
35   "2c466a2c159463f1d9ef5a7b57b52827" : "Select BCC Group",
36   "5da618e8e4b89c66fe86e32cdafde142" : "From",
37   "31bb2f6e9b8fb11cbb7fb63c6025223f" : "Select Template",
38   "b78a3223503896721cca1303f776159b" : "Title",
39   "278c491bdd8a53618c149c4ac790da34" : "Template",
40   "1351017ac6423911223bc19a8cb7c653" : "Filename",
41   "308f2757bfc9ce92fb00ff93fdffd279" : "Images / Attachments",
42   "c9cc8cce247e49bae79f15173ce97354" : "Save",
43   "5feb9bf3c03b32635135006cbacb9542" : "Insert Field",
44   "4c2a8fe7eaf24721cc7a9f0175115bd4" : "Message",
45   "fff0d600f8a0b5e19e88bfb821dd1157" : "Images"
46  },
47  "items" : [
48   {
49    "listeners" : {
50     "show" : "function (_self)\n{\n    \n    _self.layout.getRegion('center').showPanel(0);\n    var w = Roo.lib.Dom.getViewWidth();\r\n    var h = Roo.lib.Dom.getViewHeight();    \r    this.resizeTo(w-50, h-50);\r\n    this.center();\r    \n    var ew = Math.max(250, w-320);\r\n    var eh = Math.max(250, h-350) ;\r\n    var e = _this.dialog.layout.getRegion('east');\n    if (e.visible) {\n        e.hide();\n    }\n    \n    var el = _self.getEl();\n    var elw = el.dom.clientWidth;\n    \n    var bdtext = _this.form.findField('bodytext');\n    var ptext = _this.form.findField('plaintext');\n    if(bdtext.resizeEl){\n        bdtext.width = elw-100;\n        bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height  ] );\n        ptext.setSize(bdtext.width , bdtext.height);\n    }\n    \n}"
51    },
52    "modal" : true,
53    "collapsible" : false,
54    "title" : "Edit / Create Message",
55    "xtype" : "LayoutDialog",
56    "width" : 800,
57    "$ xns" : "Roo",
58    "closable" : true,
59    "resizable" : true,
60    "height" : 500,
61    "items" : [
62     {
63      "xtype" : "LayoutRegion",
64      "$ xns" : "Roo",
65      "tabPosition" : "top",
66      "* prop" : "center"
67     },
68     {
69      "hidden" : true,
70      "xtype" : "LayoutRegion",
71      "title" : "Images / Attachments",
72      "width" : 500,
73      "$ xns" : "Roo",
74      "split" : true,
75      "* prop" : "east",
76      "titlebar" : true
77     },
78     {
79      "autoScroll" : false,
80      "region" : "center",
81      "fitToFrame" : true,
82      "xtype" : "NestedLayoutPanel",
83      "fitContainer" : true,
84      "$ xns" : "Roo",
85      "items" : [
86       {
87        "xtype" : "Toolbar",
88        "$ xns" : "Roo",
89        "* prop" : "toolbar",
90        "items" : [
91         {
92          "text" : "Import",
93          "xtype" : "Button",
94          "$ xns" : "Roo.Toolbar",
95          "items" : [
96           {
97            "xtype" : "Menu",
98            "$ xns" : "Roo.menu",
99            "* prop" : "menu",
100            "items" : [
101             {
102              "listeners" : {
103               "click" : "function (_self, e)\n{\n    Pman.Dialog.CoreImportUrl.show({\n        target : '/Core/ImportMailMessage.php'\n    }, function(data) {\n        if  (data) {\n          //  Roo.log(data);\n            _this.form.findField('bodytext').setValue(data);\n        }\n    });\n}"
104              },
105              "text" : "URL",
106              "xtype" : "Item",
107              "$ xns" : "Roo.menu"
108             },
109             {
110              "listeners" : {
111               "click" : "function (_self, e)\n{\n    Pman.Dialog.Image.show({\n        _url : baseURL + '/Core/ImportMailMessage.php'\n    }, function(data) {\n        if  (data) {\n            _this.form.findField('bodytext').setValue(data);\n        }\n    });\n}"
112              },
113              "text" : "Html File",
114              "xtype" : "Item",
115              "$ xns" : "Roo.menu"
116             }
117            ]
118           }
119          ]
120         },
121         {
122          "text" : "Use template",
123          "xtype" : "Button",
124          "$ xns" : "Roo.Toolbar",
125          "items" : [
126           {
127            "xtype" : "Menu",
128            "$ xns" : "Roo.menu",
129            "* prop" : "menu",
130            "items" : [
131             {
132              "listeners" : {
133               "click" : "function (_self, e)\n{\n\n    var l = document.location;\n    new Pman.Request({\n\n        url : baseURL + '/Core/ImportMailMessage.php',\n\n        method: 'POST',\n        mask : \"Loading\",\n        params : {\n              importUrl : l.protocol +'//' + l.host +   rootURL + '/Pman/Crm/mail_templates/responsive1.html'\n       },\n        success : function (res) {\n\n         _this.form.findField('bodytext').setValue(res.data);\n        }\n  \n    });\n}"
134              },
135              "text" : "Responsive Email (1)",
136              "xtype" : "Item",
137              "$ xns" : "Roo.menu"
138             }
139            ]
140           }
141          ]
142         },
143         {
144          "listeners" : {
145           "select" : "function (combo, record, index)\n{\n   \n/*\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n*/    \n    if(!record){\n        return;\n    }\n    _this.form.findField('bodytext').setValue(record.data.content);\n\n}"
146          },
147          "alwaysQuery" : true,
148          "listWidth" : 400,
149          "triggerAction" : "all",
150          "fieldLabel" : "Template",
151          "forceSelection" : true,
152          "selectOnFocus" : true,
153          "pageSize" : 20,
154          "displayField" : "file",
155          "emptyText" : "Select Template",
156          "hiddenName" : "template",
157          "minChars" : 2,
158          "valueField" : "file",
159          "xtype" : "ComboBox",
160          "allowBlank" : true,
161          "typeAhead" : true,
162          "editable" : false,
163          "width" : 200,
164          "$ xns" : "Roo.form",
165          "name" : "template",
166          "qtip" : "Select Template",
167          "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{file}</b> </div>",
168          "loadingText" : "Searching...",
169          "items" : [
170           {
171            "listeners" : {
172             "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n   \n}\n"
173            },
174            "xtype" : "Store",
175            "remoteSort" : true,
176            "$ sortInfo" : "{ direction : 'DESC', field: 'file' }",
177            "$ xns" : "Roo.data",
178            "* prop" : "store",
179            "items" : [
180             {
181              "$ url" : "baseURL + '/Core/MailTemplateList.php'",
182              "method" : "GET",
183              "xtype" : "HttpProxy",
184              "$ xns" : "Roo.data",
185              "* prop" : "proxy"
186             },
187             {
188              "id" : "name",
189              "root" : "data",
190              "xtype" : "JsonReader",
191              "$ fields" : "[{\"name\":\"file\",\"type\":\"string\"},{\"name\":\"content\",\"type\":\"string\"}]",
192              "$ xns" : "Roo.data",
193              "* prop" : "reader",
194              "totalProperty" : "total"
195             }
196            ]
197           }
198          ]
199         },
200         {
201          "xtype" : "Fill",
202          "$ xns" : "Roo.Toolbar"
203         },
204         {
205          "listeners" : {
206           "click" : "function (_self, e)\n{\n    var el = _this.dialog.layout.getRegion('east');\n    if (el.visible) {\n        el.hide();\n    } else {\n        el.show();\n        el.showPanel(0);\n    }\n    \n}"
207          },
208          "text" : "Images / Attachments >>",
209          "xtype" : "Button",
210          "$ xns" : "Roo.Toolbar"
211         }
212        ]
213       },
214       {
215        "xtype" : "BorderLayout",
216        "$ xns" : "Roo",
217        "* prop" : "layout",
218        "items" : [
219         {
220          "autoScroll" : true,
221          "xtype" : "LayoutRegion",
222          "$ xns" : "Roo",
223          "* prop" : "center"
224         },
225         {
226          "listeners" : {
227           "resize" : "function (_self, width, height)\r\n{\r\n   var ew = Math.max(250, width-50);\r\n    var eh = Math.max(250,height-50) ;\n    \n    if (!_this.form) {\r\n        return;\r\n    }\r\n    var bdtext = _this.form.findField('bodytext');\r\n    var ptext = _this.form.findField('plaintext');\r\n    if(bdtext.resizeEl){\r\n        bdtext.width = ew-50;\r\n        bdtext.resizeEl.resizeTo.defer(110, bdtext.resizeEl,[ bdtext.width, bdtext.height  ] );\r\n        ptext.setSize(bdtext.width , bdtext.height);\r\n    }\r\r\n\r\n}",
228           "render" : "function (_self, width, height)\n{\n    \n      Roo.log(\"RESIZE, \" + width + ',' + height);\n    \n    var ew = Math.max(250, width-50);\n    var eh = Math.max(250,height-50) ;\n    \n   \n\n}"
229          },
230          "autoScroll" : false,
231          "fitToFrame" : true,
232          "background" : false,
233          "region" : "center",
234          "title" : "Message",
235          "xtype" : "ContentPanel",
236          "fitContainer" : true,
237          "$ xns" : "Roo",
238          "items" : [
239           {
240            "listeners" : {
241             "|actioncomplete" : "function(_self,action)\n{\n   \n    if (action.type == 'setdata') {\n    \n        setInterval(_this.form.findField('bodytext').autosave, 5000);\n        \n        _this.data.module = _this.data.module || 'crm_mailing_list_message';\n        \n        _this.form.url = baseURL + '/Roo/' + _this.data.module;\n        \n        _this.html_preview.hide();\n        _this.preview_btn.hide();\n            \n        if(_this.data.id*1 > 0){\n            _this.dialog.el.mask(\"Loading\");\n            this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n            _this.html_preview.show();\n            _this.preview_btn.show();\n            \n        } else {\n            _this.form.setValues({\n                'from_name' : Pman.Login.authUser.name,\n                'from_email' : Pman.Login.authUser.email\n            });\n        }\n       return;\n    }\n    if (action.type == 'load') {\n        _this.dialog.el.unmask();\n        \n        _this.form.findField('bodytext').originalValue = _this.form.findField('bodytext').getValue();\n        \n        return;\n    }\n    if (action.type =='submit') {\n    \n        _this.dialog.el.unmask();\n        _this.dialog.hide();\n    \n         if (_this.callback) {\n            _this.callback.call(_this, action.result.data);\n         }\n         _this.form.reset();\n         return;\n    }\n}\n",
242             "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
243            },
244            "labelAlign" : "right",
245            "$ preValidate" : "function(done_callback) {\n    \n    Roo.MessageBox.progress(\"Uploading Images\", \"Uploading\");\n    \n    if(!_this.form.findField('bodytext').editorcore.sourceEditMode){\n        _this.form.findField('bodytext').syncValue();\n    }else{\n        _this.form.findField('bodytext').pushValue();\n    }\n    \n    var html = _this.form.findField('bodytext').getValue();\n    \n    var s = Roo.get(_this.form.findField('bodytext').editorcore.doc.documentElement);\n    \n    var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';\n    \n    var nodes = [];\n    s.select('img[src]').each(function(i) {\n        nodes.push(i.dom);\n    });\n    var total = nodes.length;\n    var mkimg = function() {\n    \n        if (!nodes.length) {\n              Roo.MessageBox.hide();\n              _this.form.findField('bodytext').syncValue();\n              done_callback(true);\n           //    _this.form.doAction(\"submit\");\n              return;\n        }\n        var i = nodes.pop(); \n        \n        var n = i.getAttribute('src').match(/(baseURL|server_baseurl)/);\n        \n        if(n){\n            mkimg();\n            return;\n        }\n        \n        n = i.getAttribute('src').match(/^http(.*)/);\n       \n        if(!n ){\n            mkimg();\n            return;\n        }\n        \n        new Pman.Request({\n            url : baseURL + '/Roo/Images.php',\n            method : 'POST',\n            params : {\n                onid : _this.form.findField('id').getValue(),\n                ontable : ontable ,\n                _remote_upload : i.src\n            },\n            success : function(res){\n                if(res.success == true){      \n                    i.setAttribute('src', res.data);\n                    Roo.MessageBox.updateProgress( (total - nodes.length) / total , \"Done \" + (total - nodes.length) + '/' + total);\n                }\n                mkimg();\n            }\n        });\n       \n    }\n    mkimg();\n}\n",
246            "$ url" : "baseURL + '/Roo/crm_mailing_list_message.php'",
247            "method" : "POST",
248            "style" : "margin:10px",
249            "xtype" : "Form",
250            "labelWidth" : 120,
251            "$ xns" : "Roo.form",
252            "items" : [
253             {
254              "xtype" : "Row",
255              "$ xns" : "Roo.form",
256              "items" : [
257               {
258                "fieldLabel" : "Mailout Name",
259                "xtype" : "TextField",
260                "allowBlank" : false,
261                "width" : 400,
262                "$ xns" : "Roo.form",
263                "name" : "name"
264               },
265               {
266                "xtype" : "Column",
267                "$ xns" : "Roo.form",
268                "Boolean hideLabels" : true,
269                "items" : [
270                 {
271                  "listeners" : {
272                   "check" : "function (_self, checked)\n{\n    var boxLabel = 'Enabled - will be sent out';\n    \n    if(!checked){\n        boxLabel = 'Disabled - will NOT be sent out';\n    }\n    \n    this.setBoxLabel(boxLabel);\n}"
273                  },
274                  "String name" : "active",
275                  "Boolean checked" : true,
276                  "xtype" : "Checkbox",
277                  "String valueOff" : 0,
278                  "String boxLabel" : "Enabled - will be sent out",
279                  "$ xns" : "Roo.form",
280                  "Mixed value" : 1
281                 }
282                ]
283               }
284              ]
285             },
286             {
287              "xtype" : "Row",
288              "$ xns" : "Roo.form",
289              "items" : [
290               {
291                "fieldLabel" : "From",
292                "xtype" : "TextField",
293                "allowBlank" : false,
294                "width" : 300,
295                "$ xns" : "Roo.form",
296                "name" : "from_name"
297               },
298               {
299                "fieldLabel" : "Email address",
300                "xtype" : "TextField",
301                "allowBlank" : false,
302                "width" : 300,
303                "$ xns" : "Roo.form",
304                "name" : "from_email"
305               },
306               {
307                "alwaysQuery" : true,
308                "triggerAction" : "all",
309                "fieldLabel" : "BCC Group",
310                "forceSelection" : true,
311                "selectOnFocus" : true,
312                "pageSize" : 25,
313                "displayField" : "name",
314                "emptyText" : "Select BCC Group",
315                "hiddenName" : "bcc_group",
316                "minChars" : 2,
317                "valueField" : "id",
318                "xtype" : "ComboBox",
319                "allowBlank" : true,
320                "typeAhead" : true,
321                "editable" : false,
322                "width" : 300,
323                "$ xns" : "Roo.form",
324                "name" : "bcc_group_name",
325                "qtip" : "Select BCC Group",
326                "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>",
327                "loadingText" : "Searching...",
328                "Boolean forceSelection" : true,
329                "items" : [
330                 {
331                  "listeners" : {
332                   "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    \n    o.params._not_add_others = 1;\n}\n"
333                  },
334                  "xtype" : "Store",
335                  "remoteSort" : true,
336                  "$ sortInfo" : "{ direction : 'ASC', field: 'name' }",
337                  "$ xns" : "Roo.data",
338                  "* prop" : "store",
339                  "items" : [
340                   {
341                    "$ url" : "baseURL + '/Roo/Groups'",
342                    "xtype" : "HttpProxy",
343                    "method" : "GET",
344                    "$ xns" : "Roo.data",
345                    "* prop" : "proxy"
346                   },
347                   {
348                    "id" : "name",
349                    "root" : "data",
350                    "xtype" : "JsonReader",
351                    "$ fields" : "[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"id\",\"type\":\"int\"}]",
352                    "$ xns" : "Roo.data",
353                    "* prop" : "reader",
354                    "totalProperty" : "total"
355                   }
356                  ]
357                 }
358                ]
359               }
360              ]
361             },
362             {
363              "fieldLabel" : "Subject",
364              "xtype" : "TextField",
365              "allowBlank" : false,
366              "width" : 600,
367              "$ xns" : "Roo.form",
368              "name" : "subject"
369             },
370             {
371              "hideLabels" : true,
372              "xtype" : "Row",
373              "$ xns" : "Roo.form",
374              "items" : [
375               {
376                "hideLabels" : true,
377                "legend" : "Html Editor",
378                "style" : "text-align:center;",
379                "xtype" : "FieldSet",
380                "$ xns" : "Roo.form",
381                "items" : [
382                 {
383                  "listeners" : {
384                   "savedpreview" : "function (_self)\n{\n    var id = _this.form.findField('id').getValue() * 1;\n    \n    var successFn = function(res){\n        return res.data.POST.source;\n    };\n    \n    var params = {\n        action : 'AUTOSAVE',\n        remarks : 'BODY',\n        on_id : (id < 1) ? 0 : id,\n        on_table : 'crm_mailing_list_message',\n        successFn : successFn\n    };\n    \n    \n    Pman.Dialog.CoreAutoSavePreview.show(params, function(res){\n        _self.setValue(res);\n        _self.originalValue = res;\n    });\n}",
385                   "autosave" : "function (_self)\n{\n    Roo.log('autosave');\n    \n    var id = _this.form.findField('id').getValue() * 1;\n    \n    /*\n    if(!_self.editorcore.sourceEditMode){\n        _self.syncValue();\n    }else{\n        _self.pushValue();\n    }\n    */\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/Events.php',\n        method :'POST',\n        params : {\n            id : 0,\n            action : 'AUTOSAVE',\n            on_id : (id > 0) ? id : 0,\n            on_table : 'crm_mailing_list_message',\n            remarks : 'BODY',\n            source: _self.getValue()\n        },\n        success : function() {\n            _self.originalValue = _self.getValue();\n            \n        },\n        failure : function() \n        {\n            Roo.log('body autosave failed?!');\n        }\n    });\n    \n}"
386                  },
387                  "| function autosave" : "function() {\n    \n    var body = _this.form.findField('bodytext');\n    \n    if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){\n        Roo.log('body not dirty');\n        return;\n    }\n    \n    Roo.log('body dirty, auto save!');\n    \n    body.fireEvent('autosave', body);\n   \n}\n",
388                  "xtype" : "HtmlEditor",
389                  "$ cwhite" : "[ \n    'margin',\n    'padding',\n    'text-align',\n    'background',\n    'height',\n    'width',\n    'background-color',\n    'font-size',\n    'line-height',\n    'color',\n    'outline',\n    'text-decoration',\n    'position',\n    'clear',\n    'overflow',\n    'margin-top',\n    'border-bottom',\n    'top',\n    'list-style',\n    'margin-left',\n    'border',\n    'float' ,\n    'margin-right',\n    'padding-top',\n    'min-height',\n    'left',\n    'padding-left',\n    'font-weight',\n    'font-family',\n    'display',\n    'margin-bottom',\n    'padding-bottom',\n    'vertical-align',\n    'cursor',\n    'z-index',\n    'right'\n ]",
390                  "$ xns" : "Roo.form",
391                  "resizable" : "s",
392                  "name" : "bodytext",
393                  "height" : 250,
394                  "clearUp" : false,
395                  "items" : [
396                   {
397                    "xtype" : "ToolbarContext",
398                    "$ xns" : "Roo.form.HtmlEditor",
399                    "* prop" : "toolbars[]"
400                   },
401                   {
402                    "xtype" : "ToolbarStandard",
403                    "$ xns" : "Roo.form.HtmlEditor",
404                    "* prop" : "toolbars[]",
405                    "items" : [
406                     {
407                      "listeners" : {
408                       "render" : "function (_self)\n{\n    _this.extendimgselect = _self;\n}",
409                       "beforequery" : "function (combo, query, forceAll, cancel, e)\n{\n    var id = _this.form.findField('id').getValue() * 1;    \n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Save message first\");\n        return false;\n    }\n}",
410                       "select" : "function (combo, record, index)\n{\n    Roo.log(record);\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n    var editor = _this.form.findField('bodytext').editorcore;\n    \n    var curnode = editor.getSelectedNode();\n    if (curnode && curnode.tagName == 'IMG') {\n        curnode.src= String.format('{0}/Images/{1}/{2}#image-{1}',\n                baseURL,  record.data.id, record.data.filename\n            );\n            // note -forces an update... hopefully...\n        editor.owner.fireEvent('editorevent', editor, false);\n    } else {\n    \n        editor.insertAtCursor(\n            String.format('<img src=\"{0}/Images/{1}/{2}#image-{1}\">',\n            baseURL,  record.data.id, record.data.filename\n            )\n        );\n\n    }\n    \n }"
411                      },
412                      "alwaysQuery" : true,
413                      "listWidth" : 400,
414                      "triggerAction" : "all",
415                      "fieldLabel" : "Images",
416                      "forceSelection" : true,
417                      "selectOnFocus" : true,
418                      "pageSize" : 20,
419                      "displayField" : "name",
420                      "emptyText" : "Add Image",
421                      "minChars" : 2,
422                      "valueField" : "id",
423                      "xtype" : "ComboBox",
424                      "typeAhead" : true,
425                      "editable" : false,
426                      "width" : 100,
427                      "$ xns" : "Roo.form",
428                      "* prop" : "btns[]",
429                      "qtip" : "Select Images",
430                      "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>",
431                      "loadingText" : "Searching...",
432                      "items" : [
433                       {
434                        "listeners" : {
435                         "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n\n    var id = _this.form.findField('id').getValue() * 1;    \n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Save email template first\");\n        return false;\n    }\n    o.params.onid = id;\n    o.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';\n    \n   // o.params.imgtype = 'PressRelease';\n    //o.params['query[imagesize]'] = '150x150';\n    // set more here\n}\n"
436                        },
437                        "xtype" : "Store",
438                        "remoteSort" : true,
439                        "$ sortInfo" : "{ direction : 'ASC', field: 'id' }",
440                        "$ xns" : "Roo.data",
441                        "* prop" : "store",
442                        "items" : [
443                         {
444                          "$ url" : "baseURL + '/Roo/Images.php'",
445                          "xtype" : "HttpProxy",
446                          "method" : "GET",
447                          "$ xns" : "Roo.data",
448                          "* prop" : "proxy"
449                         },
450                         {
451                          "id" : "id",
452                          "root" : "data",
453                          "xtype" : "JsonReader",
454                          "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"filename\",\"type\":\"string\"},{\"name\":\"url_thumb\",\"type\":\"string\"}]",
455                          "$ xns" : "Roo.data",
456                          "* prop" : "reader",
457                          "totalProperty" : "total"
458                         }
459                        ]
460                       }
461                      ]
462                     },
463                     {
464                      "listeners" : {
465                       "render" : "function (_self)\n{\n    _this.unsubscribeselect = _self;\n}",
466                       "select" : "function (combo, record, index)\n{\n    Roo.log(record);\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n    var editor = _this.form.findField('bodytext').editorcore;\n    \n    if(record.data.name == 'Unsubscribe'){\n        editor.insertAtCursor(\n            String.format('<a href=\"{0}\">{1}</a>',\n                record.data.type,  record.data.name\n            )\n        );\n        return;     \n    }\n    \n    editor.insertAtCursor(\n        String.format('{0}',\n            record.data.type\n        )\n    );\n    \n }"
467                      },
468                      "alwaysQuery" : true,
469                      "listWidth" : 400,
470                      "triggerAction" : "all",
471                      "fieldLabel" : "Field",
472                      "forceSelection" : true,
473                      "selectOnFocus" : true,
474                      "pageSize" : 20,
475                      "displayField" : "name",
476                      "emptyText" : "Insert Field",
477                      "minChars" : 2,
478                      "valueField" : "type",
479                      "xtype" : "ComboBox",
480                      "typeAhead" : true,
481                      "editable" : false,
482                      "width" : 100,
483                      "$ xns" : "Roo.form",
484                      "* prop" : "btns[]",
485                      "qtip" : "Insert Field",
486                      "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>",
487                      "loadingText" : "Searching...",
488                      "items" : [
489                       {
490                        "xtype" : "SimpleStore",
491                        "$ data" : "[ \n    [ '{person.firstname}', \"First Name\"],\n    [ '{person.lastname}' , \"Last Name\"],\n    [ '{person.name}', \"Full Name\"],\n    [ '#unsubscribe', \"Unsubscribe\"]\n]\n",
492                        "$ fields" : "[  'type', 'name']",
493                        "$ xns" : "Roo.data",
494                        "* prop" : "store"
495                       }
496                      ]
497                     },
498                     {
499                      "xtype" : "Separator",
500                      "$ xns" : "Roo.Toolbar",
501                      "* prop" : "btns[]"
502                     },
503                     {
504                      "listeners" : {
505                       "click" : "function (_self, e)\n{\n    this.scope.owner.fireEvent('savedpreview', this.scope.owner);\n    \n}"
506                      },
507                      "String cls" : "x-init-enable",
508                      "text" : "Saved Version",
509                      "xtype" : "Button",
510                      "$ xns" : "Roo.Toolbar",
511                      "* prop" : "btns[]"
512                     }
513                    ]
514                   }
515                  ]
516                 }
517                ]
518               }
519              ]
520             },
521             {
522              "hideLabels" : true,
523              "xtype" : "Row",
524              "$ xns" : "Roo.form",
525              "items" : [
526               {
527                "listeners" : {
528                 "click" : "function (_self, e)\n{\n    var h = _this.form.findField('bodytext').getValue();\n    var p = _this.form.findField('plaintext');\n    \n    new Pman.Request({\r\n        url : baseURL + '/Core/ImportMailMessage.php',\r\n        method : 'POST',\r\n        params : {\n          bodytext : h,\r\n          _convertToPlain : true,\n          _check_unsubscribe : true\r\n        }, \r\n        success : function(res) {\r\n            if(res.success == true){\n               p.setValue(res.data);\n            }\r\n        }\r\n    });  \n    \n}"
529                },
530                "text" : "Convert Html to Text",
531                "xtype" : "Button",
532                "$ xns" : "Roo"
533               }
534              ]
535             },
536             {
537              "hideLabels" : true,
538              "xtype" : "Row",
539              "$ xns" : "Roo.form",
540              "items" : [
541               {
542                "hideLabels" : true,
543                "legend" : "Plain Text",
544                "style" : "text-align:center;",
545                "xtype" : "FieldSet",
546                "$ xns" : "Roo.form",
547                "items" : [
548                 {
549                  "xtype" : "TextArea",
550                  "$ xns" : "Roo.form",
551                  "height" : 50,
552                  "name" : "plaintext"
553                 }
554                ]
555               }
556              ]
557             },
558             {
559              "xtype" : "Hidden",
560              "$ xns" : "Roo.form",
561              "name" : "id"
562             }
563            ]
564           }
565          ]
566         }
567        ]
568       }
569      ]
570     },
571     {
572      "listeners" : {
573       "|activate" : "function() {\n    _this.ipanel = this;\n    if (_this.igrid) {\n       _this.igrid.ds.load({});\n    }\n}"
574      },
575      "autoScroll" : false,
576      "fitToframe" : true,
577      "background" : false,
578      "region" : "east",
579      "title" : "Images / Attachments",
580      "xtype" : "GridPanel",
581      "fitContainer" : true,
582      "$ xns" : "Roo",
583      "tableName" : "Images",
584      "items" : [
585       {
586        "listeners" : {
587         "|render" : "function() \n{\n    _this.igrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.ipanel.active) {\n   //    _this.igrid.ds.load({});\n    }\n}"
588        },
589        "autoExpandColumn" : "filename",
590        "xtype" : "Grid",
591        "loadMask" : true,
592        "$ xns" : "Roo.grid",
593        "* prop" : "grid",
594        "items" : [
595         {
596          "listeners" : {
597           "beforeload" : "function (_self, options)\n{\n    options.params = options.params || {};\n    if (typeof(_this.data) == 'undefined') {\n        return false;\n    }\n    if(_this.data.id * 1 >= 0)\n    {\n        options.params.onid = _this.data.id;\n\n        options.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';\n    }\n}"
598          },
599          "xtype" : "Store",
600          "remoteSort" : true,
601          "$ sortInfo" : "{ field : 'filename', direction: 'ASC' }",
602          "$ xns" : "Roo.data",
603          "* prop" : "dataSource",
604          "items" : [
605           {
606            "$ url" : "baseURL + '/Roo/Images.php'",
607            "xtype" : "HttpProxy",
608            "method" : "GET",
609            "$ xns" : "Roo.data",
610            "* prop" : "proxy"
611           },
612           {
613            "id" : "id",
614            "root" : "data",
615            "xtype" : "JsonReader",
616            "$ fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'filename',\n        'type': 'string'\n    },\n    {\n        'name': 'ontable',\n        'type': 'string'\n    },\n    {\n        'name': 'onid',\n        'type': 'int'\n    },\n    {\n        'name': 'mimetype',\n        'type': 'string'\n    },\n    {\n        'name': 'width',\n        'type': 'int'\n    },\n    {\n        'name': 'height',\n        'type': 'int'\n    },\n    {\n        'name': 'filesize',\n        'type': 'int'\n    },\n    {\n        'name': 'displayorder',\n        'type': 'int'\n    },\n    {\n        'name': 'language',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id',\n        'type': 'int'\n    },\n    {\n        'name': 'created',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'imgtype',\n        'type': 'string'\n    },\n    {\n        'name': 'linkurl',\n        'type': 'string'\n    },\n    {\n        'name': 'descript',\n        'type': 'string'\n    },\n    {\n        'name': 'title',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_filename',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_ontable',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_onid',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_mimetype',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_width',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_height',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_filesize',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_displayorder',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_language',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_parent_image_id',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_created',\n        'type': 'date'\n    },\n    {\n        'name': 'parent_image_id_imgtype',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_linkurl',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_descript',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_title',\n        'type': 'string'\n    }\n]",
617            "$ xns" : "Roo.data",
618            "* prop" : "reader",
619            "totalProperty" : "total"
620           }
621          ]
622         },
623         {
624          "xtype" : "Toolbar",
625          "$ xns" : "Roo",
626          "* prop" : "toolbar",
627          "items" : [
628           {
629            "listeners" : {
630             "|click" : "function()\n{\n    var id = _this.form.findField('id').getValue();\n    \n    if(id*1 < 1){\n        Roo.MessageBox.alert('Error', 'Please save the email template first');\n        return;\n    }\n    \n    var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';\n    \n    Pman.Dialog.Image.show( { id : 0, onid: id, ontable: ontable }, function() {\n        _this.igrid.getDataSource().load({});\n    }); \n}\n"
631            },
632            "text" : "Add",
633            "xtype" : "Button",
634            "cls" : "x-btn-text-icon",
635            "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
636            "$ xns" : "Roo.Toolbar"
637           },
638           {
639            "listeners" : {
640             "|click" : "function()\n{\n    var s = _this.igrid.getSelectionModel().getSelected();\n    if (!s || isNaN(s.id *1)) {\n        Roo.MessageBox.alert(\"Error\", \"Select a image\"); \n        return;\n    }\n    Roo.MessageBox.confirm(\"Confirm\", \"Are sure you want to delete this image?\", function (v){\n        if (v != 'yes') {\n            return;\n        }\n        \n        new Pman.Request({\n            url : baseURL + '/Roo/Images.php',\n            method: 'POST',\n            params : {\n                _delete : s.id\n            },\n            success : function()\n            {\n                Roo.log('Got Success!!');\n               _this.igrid.ds.load({});\n            }\n        });\n    });\n}\n        "
641            },
642            "text" : "Delete",
643            "xtype" : "Button",
644            "cls" : "x-btn-text-icon",
645            "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
646            "$ xns" : "Roo.Toolbar"
647           }
648          ]
649         },
650         {
651          "xtype" : "ColumnModel",
652          "width" : 300,
653          "header" : "Filename",
654          "$ renderer" : "function(v,x,r)\n{\n    var width = r.data.width;\n    var height = r.data.height;\n    \n    if(width > 50){\n        height = Math.round(height * 50 / width);\n        width = 50;\n    }\n    \n   return '<img src=\"' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '\" width=\"' + width + '\" height=\"' + height + '\" />';\n}",
655          "$ xns" : "Roo.grid",
656          "* prop" : "colModel[]",
657          "dataIndex" : "filename"
658         },
659         {
660          "xtype" : "ColumnModel",
661          "header" : "Displayorder",
662          "width" : 75,
663          "$ renderer" : "function(v) { return String.format('{0}', v); }",
664          "$ xns" : "Roo.grid",
665          "* prop" : "colModel[]",
666          "dataIndex" : "displayorder"
667         },
668         {
669          "xtype" : "ColumnModel",
670          "width" : 75,
671          "header" : "Title",
672          "$ renderer" : "function(v) { return String.format('{0}', v); }",
673          "$ xns" : "Roo.grid",
674          "* prop" : "colModel[]",
675          "dataIndex" : "title"
676         }
677        ]
678       }
679      ]
680     },
681     {
682      "listeners" : {
683       "render" : "function (_self)\n{\n    _this.preview_btn = _self;\n}",
684       "click" : "function (_self, e)\n{\n    //_this.dialog.hide();\n    Roo.log(_this.data.module);\n    Pman.Dialog.CoreEmailPreview.show({ id : _this.form.findField('id').getValue(), module : _this.data.module });\n}"
685      },
686      "text" : "Preview",
687      "xtype" : "Button",
688      "$ xns" : "Roo",
689      "* prop" : "buttons[]"
690     },
691     {
692      "listeners" : {
693       "render" : "function (_self)\n{\n    _this.html_preview = _self;\n}",
694       "click" : "function (_self, e)\n{\n    //_this.dialog.hide();\n    \n    var id = _this.form.findField('id').getValue();\n    \n    if(id*1 < 1){\n        Roo.MessageBox.alert('Error', 'Please save the message frist!');\n        return;\n    }\n   \n    new Pman.Request({\n        url : baseURL + '/Core/MessagePreview',\n        method : 'POST',\n        mask: 'Sending',\n        params : {\n            _id : id,\n            _table : _this.data.module\n        }, \n        success : function(res) { \n            if(res.data == 'SUCCESS'){\n                Roo.MessageBox.alert(\"Email Sent\", 'The report was sent to your email (HTML format).');\n            }\n        }\n    });\n}"
695      },
696      "text" : "Send me a test copy",
697      "xtype" : "Button",
698      "$ xns" : "Roo",
699      "* prop" : "buttons[]"
700     },
701     {
702      "listeners" : {
703       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n}"
704      },
705      "text" : "Cancel",
706      "xtype" : "Button",
707      "$ xns" : "Roo",
708      "* prop" : "buttons[]"
709     },
710     {
711      "listeners" : {
712       "click" : "function (_self, e)\n{\n\n    // do some checks?\n    _this.form.preValidate(function(res) {\n        if (!res) {\n            return; //failed.\n        }\n         _this.form.doAction(\"submit\");\n    });\n\n}"
713      },
714      "text" : "Save",
715      "xtype" : "Button",
716      "$ xns" : "Roo",
717      "* prop" : "buttons[]"
718     }
719    ]
720   }
721  ]
722 }