fix variables on update
[Pman.Core] / Pman.Dialog.CoreEmail.bjs
1 {
2  "name" : "Pman.Dialog.CoreEmail",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/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   "28690be026c0bb9003aa58e45e5662ca" : "Enabled - will be sent out",
16   "ea30b40c3caf28acb29198d20d243e54" : "Images / Attachments >>",
17   "31fde7b05ac8952dacf4af8a704074ec" : "Preview",
18   "b337c8a67244afb6551ee1f8f9717676" : "Test Class <BR/> (for system reference only)",
19   "884df8e413319ff51a3f5f528606238a" : "Use template",
20   "e6b391a8d2c4d45902a23a8b6585703d" : "URL",
21   "6f16a5f8ff5d75ab84c018adacdfcbb7" : "Field",
22   "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
23   "2393ad754ba179442d85e415d1d5167c" : "Displayorder",
24   "e9968623956c15023d54335ea3699855" : "Convert Html to Text",
25   "1243daf593fa297e07ab03bf06d925af" : "Searching...",
26   "5b8ef4e762c00a15a41cfc26dc3ef99c" : "Send me a test copy",
27   "c7892ebbb139886662c6f2fc8c450710" : "Subject",
28   "dc0de523c25be298ba751c63c694109e" : "Responsive Email (1)",
29   "396ecabf0cd1f9503e591418851ef406" : "Edit / Create Message",
30   "b9c49611cfda3259a2b837b39489e650" : "Add Image",
31   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
32   "68b00d723d37122f64da8d9939f836f0" : "BCC Group",
33   "c4ca4238a0b923820dcc509a6f75849b" : "1",
34   "bd88a20b53a47f7b5704a83a15ff5506" : "Saved Version",
35   "b20a8b77b05d53b4e695738731400c85" : "Mailout Name",
36   "1bd18d39370b7f26c1c5e18067b74c6f" : "Html File",
37   "2c466a2c159463f1d9ef5a7b57b52827" : "Select BCC Group",
38   "5da618e8e4b89c66fe86e32cdafde142" : "From",
39   "31bb2f6e9b8fb11cbb7fb63c6025223f" : "Select Template",
40   "b78a3223503896721cca1303f776159b" : "Title",
41   "278c491bdd8a53618c149c4ac790da34" : "Template",
42   "1351017ac6423911223bc19a8cb7c653" : "Filename",
43   "308f2757bfc9ce92fb00ff93fdffd279" : "Images / Attachments",
44   "c9cc8cce247e49bae79f15173ce97354" : "Save",
45   "5feb9bf3c03b32635135006cbacb9542" : "Insert Field",
46   "4c2a8fe7eaf24721cc7a9f0175115bd4" : "Message",
47   "fff0d600f8a0b5e19e88bfb821dd1157" : "Images"
48  },
49  "named_strings" : {
50   "active_boxLabel" : "28690be026c0bb9003aa58e45e5662ca",
51   "template_fieldLabel" : "278c491bdd8a53618c149c4ac790da34",
52   "name_fieldLabel" : "b20a8b77b05d53b4e695738731400c85",
53   "bcc_group_id_name_qtip" : "2c466a2c159463f1d9ef5a7b57b52827",
54   "bcc_group_id_name_emptyText" : "2c466a2c159463f1d9ef5a7b57b52827",
55   "template_qtip" : "31bb2f6e9b8fb11cbb7fb63c6025223f",
56   "template_loadingText" : "1243daf593fa297e07ab03bf06d925af",
57   "from_email_fieldLabel" : "b357b524e740bc85b9790a0712d84a30",
58   "template_emptyText" : "31bb2f6e9b8fb11cbb7fb63c6025223f",
59   "active_value" : "c4ca4238a0b923820dcc509a6f75849b",
60   "from_name_fieldLabel" : "5da618e8e4b89c66fe86e32cdafde142",
61   "bcc_group_id_name_loadingText" : "1243daf593fa297e07ab03bf06d925af",
62   "bcc_group_id_name_fieldLabel" : "68b00d723d37122f64da8d9939f836f0",
63   "subject_fieldLabel" : "c7892ebbb139886662c6f2fc8c450710",
64   "test_class_fieldLabel" : "b337c8a67244afb6551ee1f8f9717676"
65  },
66  "items" : [
67   {
68    "listeners" : {
69     "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}"
70    },
71    "modal" : true,
72    "collapsible" : false,
73    "title" : "Edit / Create Message",
74    "xtype" : "LayoutDialog",
75    "width" : 800,
76    "$ xns" : "Roo",
77    "closable" : true,
78    "resizable" : true,
79    "height" : 500,
80    "items" : [
81     {
82      "xtype" : "LayoutRegion",
83      "$ xns" : "Roo",
84      "tabPosition" : "top",
85      "* prop" : "center"
86     },
87     {
88      "hidden" : true,
89      "xtype" : "LayoutRegion",
90      "title" : "Images / Attachments",
91      "width" : 500,
92      "$ xns" : "Roo",
93      "split" : true,
94      "* prop" : "east",
95      "titlebar" : true
96     },
97     {
98      "autoScroll" : false,
99      "region" : "center",
100      "fitToFrame" : true,
101      "xtype" : "NestedLayoutPanel",
102      "fitContainer" : true,
103      "$ xns" : "Roo",
104      "items" : [
105       {
106        "xtype" : "Toolbar",
107        "$ xns" : "Roo",
108        "* prop" : "toolbar",
109        "items" : [
110         {
111          "text" : "Import",
112          "xtype" : "Button",
113          "$ xns" : "Roo.Toolbar",
114          "items" : [
115           {
116            "xtype" : "Menu",
117            "$ xns" : "Roo.menu",
118            "* prop" : "menu",
119            "items" : [
120             {
121              "listeners" : {
122               "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}"
123              },
124              "text" : "URL",
125              "xtype" : "Item",
126              "$ xns" : "Roo.menu"
127             },
128             {
129              "listeners" : {
130               "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}"
131              },
132              "text" : "Html File",
133              "xtype" : "Item",
134              "$ xns" : "Roo.menu"
135             }
136            ]
137           }
138          ]
139         },
140         {
141          "text" : "Use template",
142          "xtype" : "Button",
143          "$ xns" : "Roo.Toolbar",
144          "items" : [
145           {
146            "xtype" : "Menu",
147            "$ xns" : "Roo.menu",
148            "* prop" : "menu",
149            "items" : [
150             {
151              "listeners" : {
152               "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}"
153              },
154              "text" : "Responsive Email (1)",
155              "xtype" : "Item",
156              "$ xns" : "Roo.menu"
157             }
158            ]
159           }
160          ]
161         },
162         {
163          "listeners" : {
164           "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}"
165          },
166          "alwaysQuery" : true,
167          "listWidth" : 400,
168          "triggerAction" : "all",
169          "fieldLabel" : "Template",
170          "forceSelection" : true,
171          "selectOnFocus" : true,
172          "pageSize" : 20,
173          "displayField" : "file",
174          "emptyText" : "Select Template",
175          "hiddenName" : "template",
176          "minChars" : 2,
177          "valueField" : "file",
178          "xtype" : "ComboBox",
179          "allowBlank" : true,
180          "typeAhead" : true,
181          "editable" : false,
182          "width" : 200,
183          "$ xns" : "Roo.form",
184          "name" : "template",
185          "qtip" : "Select Template",
186          "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{file}</b> </div>",
187          "loadingText" : "Searching...",
188          "items" : [
189           {
190            "listeners" : {
191             "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n   \n}\n"
192            },
193            "xtype" : "Store",
194            "remoteSort" : true,
195            "$ sortInfo" : "{ direction : 'DESC', field: 'file' }",
196            "$ xns" : "Roo.data",
197            "* prop" : "store",
198            "items" : [
199             {
200              "$ url" : "baseURL + '/Core/MailTemplateList.php'",
201              "method" : "GET",
202              "xtype" : "HttpProxy",
203              "$ xns" : "Roo.data",
204              "* prop" : "proxy"
205             },
206             {
207              "id" : "name",
208              "root" : "data",
209              "xtype" : "JsonReader",
210              "$ fields" : "[{\"name\":\"file\",\"type\":\"string\"},{\"name\":\"content\",\"type\":\"string\"}]",
211              "$ xns" : "Roo.data",
212              "* prop" : "reader",
213              "totalProperty" : "total"
214             }
215            ]
216           }
217          ]
218         },
219         {
220          "xtype" : "Fill",
221          "$ xns" : "Roo.Toolbar"
222         },
223         {
224          "listeners" : {
225           "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}"
226          },
227          "text" : "Images / Attachments >>",
228          "xtype" : "Button",
229          "$ xns" : "Roo.Toolbar"
230         }
231        ]
232       },
233       {
234        "xtype" : "BorderLayout",
235        "$ xns" : "Roo",
236        "* prop" : "layout",
237        "items" : [
238         {
239          "autoScroll" : true,
240          "xtype" : "LayoutRegion",
241          "$ xns" : "Roo",
242          "* prop" : "center"
243         },
244         {
245          "listeners" : {
246           "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}",
247           "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}"
248          },
249          "autoScroll" : false,
250          "fitToFrame" : true,
251          "background" : false,
252          "region" : "center",
253          "title" : "Message",
254          "xtype" : "ContentPanel",
255          "fitContainer" : true,
256          "$ xns" : "Roo",
257          "items" : [
258           {
259            "listeners" : {
260             "|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",
261             "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
262            },
263            "$ 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    \n    if (!_this.form.findField('bodytext').getValue().match(/unsubscribe/i)) {\n        Roo.MessageBox.confirm(\"Missing unusubscribe\",\n            \"There is no unsubscribe link on the email  are you sure you want to save it\",\n            function(res) {\n                if (res == 'no') {\n                    return;\n                }\n                mkimg();\n            }\n        );\n\n        return;\n    }\n    \n    mkimg();\n}\n",
264            "$ url" : "baseURL + '/Roo/crm_mailing_list_message.php'",
265            "labelAlign" : "right",
266            "method" : "POST",
267            "style" : "margin:10px",
268            "xtype" : "Form",
269            "labelWidth" : 120,
270            "$ xns" : "Roo.form",
271            "items" : [
272             {
273              "xtype" : "Row",
274              "$ xns" : "Roo.form",
275              "items" : [
276               {
277                "fieldLabel" : "Mailout Name",
278                "xtype" : "TextField",
279                "allowBlank" : false,
280                "width" : 400,
281                "$ xns" : "Roo.form",
282                "name" : "name"
283               },
284               {
285                "xtype" : "Column",
286                "$ xns" : "Roo.form",
287                "Boolean hideLabels" : true,
288                "items" : [
289                 {
290                  "listeners" : {
291                   "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}"
292                  },
293                  "String name" : "active",
294                  "Boolean checked" : true,
295                  "xtype" : "Checkbox",
296                  "String valueOff" : 0,
297                  "String boxLabel" : "Enabled - will be sent out",
298                  "$ xns" : "Roo.form",
299                  "Mixed value" : 1
300                 }
301                ]
302               }
303              ]
304             },
305             {
306              "xtype" : "Row",
307              "$ xns" : "Roo.form",
308              "items" : [
309               {
310                "fieldLabel" : "From",
311                "xtype" : "TextField",
312                "allowBlank" : false,
313                "width" : 300,
314                "$ xns" : "Roo.form",
315                "name" : "from_name"
316               },
317               {
318                "fieldLabel" : "Email address",
319                "xtype" : "TextField",
320                "allowBlank" : false,
321                "width" : 300,
322                "$ xns" : "Roo.form",
323                "name" : "from_email"
324               },
325               {
326                "alwaysQuery" : true,
327                "triggerAction" : "all",
328                "fieldLabel" : "BCC Group",
329                "forceSelection" : true,
330                "selectOnFocus" : true,
331                "pageSize" : 25,
332                "displayField" : "name",
333                "emptyText" : "Select BCC Group",
334                "hiddenName" : "bcc_group_id",
335                "minChars" : 2,
336                "valueField" : "id",
337                "xtype" : "ComboBox",
338                "allowBlank" : true,
339                "typeAhead" : true,
340                "editable" : false,
341                "width" : 300,
342                "$ xns" : "Roo.form",
343                "name" : "bcc_group_id_name",
344                "qtip" : "Select BCC Group",
345                "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>",
346                "loadingText" : "Searching...",
347                "Boolean forceSelection" : true,
348                "items" : [
349                 {
350                  "listeners" : {
351                   "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    \n    o.params._direct_return = 1;\n}\n"
352                  },
353                  "xtype" : "Store",
354                  "remoteSort" : true,
355                  "$ sortInfo" : "{ direction : 'ASC', field: 'name' }",
356                  "$ xns" : "Roo.data",
357                  "* prop" : "store",
358                  "items" : [
359                   {
360                    "$ url" : "baseURL + '/Roo/Core_group'",
361                    "xtype" : "HttpProxy",
362                    "method" : "GET",
363                    "$ xns" : "Roo.data",
364                    "* prop" : "proxy"
365                   },
366                   {
367                    "id" : "name",
368                    "root" : "data",
369                    "xtype" : "JsonReader",
370                    "$ fields" : "[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"id\",\"type\":\"int\"}]",
371                    "$ xns" : "Roo.data",
372                    "* prop" : "reader",
373                    "totalProperty" : "total"
374                   }
375                  ]
376                 }
377                ]
378               }
379              ]
380             },
381             {
382              "fieldLabel" : "Subject",
383              "xtype" : "TextField",
384              "allowBlank" : false,
385              "width" : 600,
386              "$ xns" : "Roo.form",
387              "name" : "subject"
388             },
389             {
390              "hideLabels" : true,
391              "xtype" : "Row",
392              "$ xns" : "Roo.form",
393              "items" : [
394               {
395                "hideLabels" : true,
396                "legend" : "Html Editor",
397                "style" : "text-align:center;",
398                "xtype" : "FieldSet",
399                "$ xns" : "Roo.form",
400                "items" : [
401                 {
402                  "listeners" : {
403                   "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}",
404                   "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}"
405                  },
406                  "xtype" : "HtmlEditor",
407                  "$ 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 ]",
408                  "| 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",
409                  "$ xns" : "Roo.form",
410                  "resizable" : "s",
411                  "name" : "bodytext",
412                  "height" : 250,
413                  "clearUp" : false,
414                  "items" : [
415                   {
416                    "xtype" : "ToolbarContext",
417                    "$ xns" : "Roo.form.HtmlEditor",
418                    "* prop" : "toolbars[]"
419                   },
420                   {
421                    "xtype" : "ToolbarStandard",
422                    "$ xns" : "Roo.form.HtmlEditor",
423                    "* prop" : "toolbars[]",
424                    "items" : [
425                     {
426                      "listeners" : {
427                       "render" : "function (_self)\n{\n    _this.extendimgselect = _self;\n}",
428                       "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}",
429                       "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 }"
430                      },
431                      "alwaysQuery" : true,
432                      "listWidth" : 400,
433                      "triggerAction" : "all",
434                      "fieldLabel" : "Images",
435                      "forceSelection" : true,
436                      "selectOnFocus" : true,
437                      "pageSize" : 20,
438                      "displayField" : "name",
439                      "emptyText" : "Add Image",
440                      "minChars" : 2,
441                      "valueField" : "id",
442                      "xtype" : "ComboBox",
443                      "typeAhead" : true,
444                      "editable" : false,
445                      "width" : 100,
446                      "$ xns" : "Roo.form",
447                      "* prop" : "btns[]",
448                      "qtip" : "Select Images",
449                      "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>",
450                      "loadingText" : "Searching...",
451                      "items" : [
452                       {
453                        "listeners" : {
454                         "|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"
455                        },
456                        "xtype" : "Store",
457                        "remoteSort" : true,
458                        "$ sortInfo" : "{ direction : 'ASC', field: 'id' }",
459                        "$ xns" : "Roo.data",
460                        "* prop" : "store",
461                        "items" : [
462                         {
463                          "$ url" : "baseURL + '/Roo/Images.php'",
464                          "xtype" : "HttpProxy",
465                          "method" : "GET",
466                          "$ xns" : "Roo.data",
467                          "* prop" : "proxy"
468                         },
469                         {
470                          "id" : "id",
471                          "root" : "data",
472                          "xtype" : "JsonReader",
473                          "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"filename\",\"type\":\"string\"},{\"name\":\"url_thumb\",\"type\":\"string\"}]",
474                          "$ xns" : "Roo.data",
475                          "* prop" : "reader",
476                          "totalProperty" : "total"
477                         }
478                        ]
479                       }
480                      ]
481                     },
482                     {
483                      "listeners" : {
484                       "render" : "function (_self)\n{\n    _this.unsubscribeselect = _self;\n}",
485                       "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 }"
486                      },
487                      "alwaysQuery" : true,
488                      "listWidth" : 400,
489                      "triggerAction" : "all",
490                      "fieldLabel" : "Field",
491                      "forceSelection" : true,
492                      "selectOnFocus" : true,
493                      "pageSize" : 20,
494                      "displayField" : "name",
495                      "emptyText" : "Insert Field",
496                      "minChars" : 2,
497                      "valueField" : "type",
498                      "xtype" : "ComboBox",
499                      "typeAhead" : true,
500                      "editable" : false,
501                      "width" : 100,
502                      "$ xns" : "Roo.form",
503                      "* prop" : "btns[]",
504                      "qtip" : "Insert Field",
505                      "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>",
506                      "loadingText" : "Searching...",
507                      "items" : [
508                       {
509                        "xtype" : "SimpleStore",
510                        "$ data" : "[ \n    [ '{person.firstname}', \"First Name\"],\n    [ '{person.lastname}' , \"Last Name\"],\n    [ '{person.name}', \"Full Name\"],\n    [ '#unsubscribe', \"Unsubscribe\"]\n]\n",
511                        "$ fields" : "[  'type', 'name']",
512                        "$ xns" : "Roo.data",
513                        "* prop" : "store"
514                       }
515                      ]
516                     },
517                     {
518                      "xtype" : "Separator",
519                      "$ xns" : "Roo.Toolbar",
520                      "* prop" : "btns[]"
521                     },
522                     {
523                      "listeners" : {
524                       "click" : "function (_self, e)\n{\n    this.scope.owner.fireEvent('savedpreview', this.scope.owner);\n    \n}"
525                      },
526                      "String cls" : "x-init-enable",
527                      "text" : "Saved Version",
528                      "xtype" : "Button",
529                      "$ xns" : "Roo.Toolbar",
530                      "* prop" : "btns[]"
531                     }
532                    ]
533                   }
534                  ]
535                 }
536                ]
537               }
538              ]
539             },
540             {
541              "hideLabels" : true,
542              "xtype" : "Row",
543              "$ xns" : "Roo.form",
544              "items" : [
545               {
546                "listeners" : {
547                 "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}"
548                },
549                "text" : "Convert Html to Text",
550                "xtype" : "Button",
551                "$ xns" : "Roo"
552               }
553              ]
554             },
555             {
556              "hideLabels" : true,
557              "xtype" : "Row",
558              "$ xns" : "Roo.form",
559              "items" : [
560               {
561                "hideLabels" : true,
562                "legend" : "Plain Text",
563                "style" : "text-align:center;",
564                "xtype" : "FieldSet",
565                "$ xns" : "Roo.form",
566                "items" : [
567                 {
568                  "xtype" : "TextArea",
569                  "$ xns" : "Roo.form",
570                  "height" : 50,
571                  "name" : "plaintext"
572                 }
573                ]
574               }
575              ]
576             },
577             {
578              "xtype" : "Row",
579              "$ xns" : "Roo.form",
580              "items" : [
581               {
582                "fieldLabel" : "Test Class <BR/> (for system reference only)",
583                "Boolean readOnly" : true,
584                "xtype" : "TextField",
585                "allowBlank" : true,
586                "width" : 300,
587                "$ xns" : "Roo.form",
588                "name" : "test_class"
589               }
590              ]
591             },
592             {
593              "xtype" : "Hidden",
594              "$ xns" : "Roo.form",
595              "name" : "id"
596             }
597            ]
598           }
599          ]
600         }
601        ]
602       }
603      ]
604     },
605     {
606      "listeners" : {
607       "|activate" : "function() {\n    _this.ipanel = this;\n    if (_this.igrid) {\n       _this.igrid.ds.load({});\n    }\n}"
608      },
609      "autoScroll" : false,
610      "fitToframe" : true,
611      "background" : false,
612      "region" : "east",
613      "title" : "Images / Attachments",
614      "xtype" : "GridPanel",
615      "fitContainer" : true,
616      "$ xns" : "Roo",
617      "tableName" : "Images",
618      "items" : [
619       {
620        "listeners" : {
621         "|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}"
622        },
623        "autoExpandColumn" : "filename",
624        "xtype" : "Grid",
625        "loadMask" : true,
626        "$ xns" : "Roo.grid",
627        "* prop" : "grid",
628        "items" : [
629         {
630          "listeners" : {
631           "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}"
632          },
633          "xtype" : "Store",
634          "remoteSort" : true,
635          "$ sortInfo" : "{ field : 'filename', direction: 'ASC' }",
636          "$ xns" : "Roo.data",
637          "* prop" : "dataSource",
638          "items" : [
639           {
640            "$ url" : "baseURL + '/Roo/Images.php'",
641            "xtype" : "HttpProxy",
642            "method" : "GET",
643            "$ xns" : "Roo.data",
644            "* prop" : "proxy"
645           },
646           {
647            "id" : "id",
648            "root" : "data",
649            "xtype" : "JsonReader",
650            "$ 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]",
651            "$ xns" : "Roo.data",
652            "* prop" : "reader",
653            "totalProperty" : "total"
654           }
655          ]
656         },
657         {
658          "xtype" : "Toolbar",
659          "$ xns" : "Roo",
660          "* prop" : "toolbar",
661          "items" : [
662           {
663            "listeners" : {
664             "|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"
665            },
666            "text" : "Add",
667            "xtype" : "Button",
668            "cls" : "x-btn-text-icon",
669            "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
670            "$ xns" : "Roo.Toolbar"
671           },
672           {
673            "listeners" : {
674             "|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        "
675            },
676            "text" : "Delete",
677            "xtype" : "Button",
678            "cls" : "x-btn-text-icon",
679            "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
680            "$ xns" : "Roo.Toolbar"
681           }
682          ]
683         },
684         {
685          "xtype" : "ColumnModel",
686          "width" : 300,
687          "header" : "Filename",
688          "$ 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}",
689          "$ xns" : "Roo.grid",
690          "* prop" : "colModel[]",
691          "dataIndex" : "filename"
692         },
693         {
694          "xtype" : "ColumnModel",
695          "header" : "Displayorder",
696          "width" : 75,
697          "$ renderer" : "function(v) { return String.format('{0}', v); }",
698          "$ xns" : "Roo.grid",
699          "* prop" : "colModel[]",
700          "dataIndex" : "displayorder"
701         },
702         {
703          "xtype" : "ColumnModel",
704          "width" : 75,
705          "header" : "Title",
706          "$ renderer" : "function(v) { return String.format('{0}', v); }",
707          "$ xns" : "Roo.grid",
708          "* prop" : "colModel[]",
709          "dataIndex" : "title"
710         }
711        ]
712       }
713      ]
714     },
715     {
716      "listeners" : {
717       "render" : "function (_self)\n{\n    _this.preview_btn = _self;\n}",
718       "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}"
719      },
720      "text" : "Preview",
721      "xtype" : "Button",
722      "$ xns" : "Roo",
723      "* prop" : "buttons[]"
724     },
725     {
726      "listeners" : {
727       "render" : "function (_self)\n{\n    _this.html_preview = _self;\n}",
728       "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}"
729      },
730      "text" : "Send me a test copy",
731      "xtype" : "Button",
732      "$ xns" : "Roo",
733      "* prop" : "buttons[]"
734     },
735     {
736      "listeners" : {
737       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n}"
738      },
739      "text" : "Cancel",
740      "xtype" : "Button",
741      "$ xns" : "Roo",
742      "* prop" : "buttons[]"
743     },
744     {
745      "listeners" : {
746       "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}"
747      },
748      "text" : "Save",
749      "xtype" : "Button",
750      "$ xns" : "Roo",
751      "* prop" : "buttons[]"
752     }
753    ]
754   }
755  ]
756 }