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