Pman.Dialog.CoreEmail.bjs
[Pman.Core] / Pman.Dialog.CoreEmail.bjs
1 {
2  "name" : "Pman.Dialog.CoreEmail",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/edward/gitlive/Pman.Core/Pman.Dialog.CoreEmail.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "308f2757bfc9ce92fb00ff93fdffd279" : "Images / Attachments",
10   "dc0de523c25be298ba751c63c694109e" : "Responsive Email (1)",
11   "ea30b40c3caf28acb29198d20d243e54" : "Images / Attachments >>",
12   "4c2a8fe7eaf24721cc7a9f0175115bd4" : "Message",
13   "2f26e35d61be90501e099089dc533638" : "Select Images",
14   "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
15   "72d6d7a1885885bb55a565fd1070581a" : "Import",
16   "884df8e413319ff51a3f5f528606238a" : "Use template",
17   "396ecabf0cd1f9503e591418851ef406" : "Edit / Create Message",
18   "31bb2f6e9b8fb11cbb7fb63c6025223f" : "Select Template",
19   "1bd18d39370b7f26c1c5e18067b74c6f" : "Html File",
20   "1243daf593fa297e07ab03bf06d925af" : "Searching...",
21   "b78a3223503896721cca1303f776159b" : "Title",
22   "31fde7b05ac8952dacf4af8a704074ec" : "Preview",
23   "5b8ef4e762c00a15a41cfc26dc3ef99c" : "Send me a test copy",
24   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
25   "962b90039a542a29cedd51d87a9f28a1" : "Html Editor",
26   "5feb9bf3c03b32635135006cbacb9542" : "Insert Field",
27   "2393ad754ba179442d85e415d1d5167c" : "Displayorder",
28   "b9c49611cfda3259a2b837b39489e650" : "Add Image",
29   "e44b145bd8b49b06e0ad2ced1ad56466" : "Plain Text",
30   "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
31   "1351017ac6423911223bc19a8cb7c653" : "Filename",
32   "c9cc8cce247e49bae79f15173ce97354" : "Save",
33   "e6b391a8d2c4d45902a23a8b6585703d" : "URL",
34   "e9968623956c15023d54335ea3699855" : "Convert Html to Text"
35  },
36  "items" : [
37   {
38    "listeners" : {
39     "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}"
40    },
41    "modal" : true,
42    "collapsible" : false,
43    "title" : "Edit / Create Message",
44    "xtype" : "LayoutDialog",
45    "width" : 800,
46    "$ xns" : "Roo",
47    "closable" : true,
48    "resizable" : true,
49    "height" : 500,
50    "items" : [
51     {
52      "xtype" : "LayoutRegion",
53      "$ xns" : "Roo",
54      "tabPosition" : "top",
55      "* prop" : "center"
56     },
57     {
58      "hidden" : true,
59      "xtype" : "LayoutRegion",
60      "title" : "Images / Attachments",
61      "width" : 500,
62      "$ xns" : "Roo",
63      "split" : true,
64      "* prop" : "east",
65      "titlebar" : true
66     },
67     {
68      "autoScroll" : false,
69      "region" : "center",
70      "fitToFrame" : true,
71      "xtype" : "NestedLayoutPanel",
72      "fitContainer" : true,
73      "$ xns" : "Roo",
74      "items" : [
75       {
76        "xtype" : "Toolbar",
77        "$ xns" : "Roo",
78        "* prop" : "toolbar",
79        "items" : [
80         {
81          "text" : "Import",
82          "xtype" : "Button",
83          "$ xns" : "Roo.Toolbar",
84          "items" : [
85           {
86            "xtype" : "Menu",
87            "$ xns" : "Roo.menu",
88            "* prop" : "menu",
89            "items" : [
90             {
91              "listeners" : {
92               "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}"
93              },
94              "text" : "URL",
95              "xtype" : "Item",
96              "$ xns" : "Roo.menu"
97             },
98             {
99              "listeners" : {
100               "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}"
101              },
102              "text" : "Html File",
103              "xtype" : "Item",
104              "$ xns" : "Roo.menu"
105             }
106            ]
107           }
108          ]
109         },
110         {
111          "text" : "Use template",
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\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}"
123              },
124              "text" : "Responsive Email (1)",
125              "xtype" : "Item",
126              "$ xns" : "Roo.menu"
127             }
128            ]
129           }
130          ]
131         },
132         {
133          "listeners" : {
134           "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}"
135          },
136          "alwaysQuery" : true,
137          "listWidth" : 400,
138          "triggerAction" : "all",
139          "fieldLabel" : "Template",
140          "forceSelection" : true,
141          "selectOnFocus" : true,
142          "pageSize" : 20,
143          "displayField" : "file",
144          "emptyText" : "Select Template",
145          "hiddenName" : "template",
146          "minChars" : 2,
147          "valueField" : "file",
148          "xtype" : "ComboBox",
149          "allowBlank" : true,
150          "typeAhead" : true,
151          "editable" : false,
152          "width" : 200,
153          "$ xns" : "Roo.form",
154          "name" : "template",
155          "qtip" : "Select Template",
156          "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{file}</b> </div>",
157          "loadingText" : "Searching...",
158          "items" : [
159           {
160            "listeners" : {
161             "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n   \n}\n"
162            },
163            "xtype" : "Store",
164            "remoteSort" : true,
165            "$ sortInfo" : "{ direction : 'DESC', field: 'file' }",
166            "$ xns" : "Roo.data",
167            "* prop" : "store",
168            "items" : [
169             {
170              "$ url" : "baseURL + '/Core/MailTemplateList.php'",
171              "method" : "GET",
172              "xtype" : "HttpProxy",
173              "$ xns" : "Roo.data",
174              "* prop" : "proxy"
175             },
176             {
177              "id" : "name",
178              "root" : "data",
179              "xtype" : "JsonReader",
180              "$ fields" : "[{\"name\":\"file\",\"type\":\"string\"},{\"name\":\"content\",\"type\":\"string\"}]",
181              "$ xns" : "Roo.data",
182              "* prop" : "reader",
183              "totalProperty" : "total"
184             }
185            ]
186           }
187          ]
188         },
189         {
190          "xtype" : "Fill",
191          "$ xns" : "Roo.Toolbar"
192         },
193         {
194          "listeners" : {
195           "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}"
196          },
197          "text" : "Images / Attachments >>",
198          "xtype" : "Button",
199          "$ xns" : "Roo.Toolbar"
200         }
201        ]
202       },
203       {
204        "xtype" : "BorderLayout",
205        "$ xns" : "Roo",
206        "* prop" : "layout",
207        "items" : [
208         {
209          "autoScroll" : true,
210          "xtype" : "LayoutRegion",
211          "$ xns" : "Roo",
212          "* prop" : "center"
213         },
214         {
215          "listeners" : {
216           "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}",
217           "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}"
218          },
219          "autoScroll" : false,
220          "fitToFrame" : true,
221          "background" : false,
222          "region" : "center",
223          "title" : "Message",
224          "xtype" : "ContentPanel",
225          "fitContainer" : true,
226          "$ xns" : "Roo",
227          "items" : [
228           {
229            "listeners" : {
230             "|actioncomplete" : "function(_self,action)\n{\n   \n    if (action.type == 'setdata') {\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        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",
231             "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
232            },
233            "$ url" : "baseURL + '/Roo/crm_mailing_list_message.php'",
234            "labelAlign" : "right",
235            "$ preValidate" : "function(done_callback) {\n    \n    Roo.MessageBox.progress(\"Uploading Images\", \"Uploading\");\n    var html = _this.form.findField('bodytext').getValue();\n    \n    var s = Roo.get(_this.form.findField('bodytext').editorcore.doc.documentElement);\n    \n    var ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';\n    \n    var nodes = [];\n    s.select('img[src]').each(function(i) {\n        nodes.push(i.dom);\n    });\n    var total = nodes.length;\n    var mkimg = function() {\n    \n        if (!nodes.length) {\n              Roo.MessageBox.hide();\n              _this.form.findField('bodytext').syncValue();\n              done_callback(true);\n           //    _this.form.doAction(\"submit\");\n              return;\n        }\n        var i = nodes.pop(); \n        \n        var n = i.getAttribute('src').match(/(baseURL|server_baseurl)/);\n        \n        if(n){\n            mkimg();\n            return;\n        }\n        \n        n = i.getAttribute('src').match(/^http(.*)/)\n       \n        if(!n ){\n            mkimg();\n            return;\n        }\n        \n        new Pman.Request({\n            url : baseURL + '/Roo/Images.php',\n            method : 'POST',\n            params : {\n                onid : _this.form.findField('id').getValue(),\n                ontable : ontable ,\n                _remote_upload : i.src\n            },\n            success : function(res){\n                if(res.success == true){      \n                    i.setAttribute('src', res.data);\n                    Roo.MessageBox.updateProgress( (total - nodes.length) / total , \"Done \" + (total - nodes.length) + '/' + total);\n                }\n                mkimg();\n            }\n        });\n       \n    }\n    mkimg();\n}\n",
236            "method" : "POST",
237            "style" : "margin:10px",
238            "xtype" : "Form",
239            "labelWidth" : 120,
240            "$ xns" : "Roo.form",
241            "items" : [
242             {
243              "xtype" : "Row",
244              "$ xns" : "Roo.form",
245              "items" : [
246               {
247                "fieldLabel" : "Mailout Name",
248                "xtype" : "TextField",
249                "allowBlank" : false,
250                "width" : 400,
251                "$ xns" : "Roo.form",
252                "name" : "name"
253               }
254              ]
255             },
256             {
257              "xtype" : "Row",
258              "$ xns" : "Roo.form",
259              "items" : [
260               {
261                "fieldLabel" : "From",
262                "xtype" : "TextField",
263                "allowBlank" : false,
264                "width" : 300,
265                "$ xns" : "Roo.form",
266                "name" : "from_name"
267               },
268               {
269                "fieldLabel" : "Email address",
270                "xtype" : "TextField",
271                "allowBlank" : false,
272                "width" : 300,
273                "$ xns" : "Roo.form",
274                "name" : "from_email"
275               }
276              ]
277             },
278             {
279              "fieldLabel" : "Subject",
280              "xtype" : "TextField",
281              "allowBlank" : false,
282              "width" : 600,
283              "$ xns" : "Roo.form",
284              "name" : "subject"
285             },
286             {
287              "hideLabels" : true,
288              "xtype" : "Row",
289              "$ xns" : "Roo.form",
290              "items" : [
291               {
292                "hideLabels" : true,
293                "legend" : "Html Editor",
294                "style" : "text-align:center;",
295                "xtype" : "FieldSet",
296                "$ xns" : "Roo.form",
297                "items" : [
298                 {
299                  "xtype" : "HtmlEditor",
300                  "$ 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 ]",
301                  "$ xns" : "Roo.form",
302                  "resizable" : "s",
303                  "name" : "bodytext",
304                  "height" : 250,
305                  "clearUp" : false,
306                  "items" : [
307                   {
308                    "xtype" : "ToolbarContext",
309                    "$ xns" : "Roo.form.HtmlEditor",
310                    "* prop" : "toolbars[]"
311                   },
312                   {
313                    "xtype" : "ToolbarStandard",
314                    "$ xns" : "Roo.form.HtmlEditor",
315                    "* prop" : "toolbars[]",
316                    "items" : [
317                     {
318                      "listeners" : {
319                       "render" : "function (_self)\n{\n    _this.extendimgselect = _self;\n}",
320                       "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}",
321                       "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    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 }"
322                      },
323                      "alwaysQuery" : true,
324                      "listWidth" : 400,
325                      "triggerAction" : "all",
326                      "fieldLabel" : "Images",
327                      "forceSelection" : true,
328                      "selectOnFocus" : true,
329                      "pageSize" : 20,
330                      "displayField" : "name",
331                      "emptyText" : "Add Image",
332                      "minChars" : 2,
333                      "valueField" : "id",
334                      "xtype" : "ComboBox",
335                      "typeAhead" : true,
336                      "editable" : false,
337                      "width" : 100,
338                      "$ xns" : "Roo.form",
339                      "* prop" : "btns[]",
340                      "qtip" : "Select Images",
341                      "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>",
342                      "loadingText" : "Searching...",
343                      "items" : [
344                       {
345                        "listeners" : {
346                         "|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"
347                        },
348                        "xtype" : "Store",
349                        "remoteSort" : true,
350                        "$ sortInfo" : "{ direction : 'ASC', field: 'id' }",
351                        "$ xns" : "Roo.data",
352                        "* prop" : "store",
353                        "items" : [
354                         {
355                          "$ url" : "baseURL + '/Roo/Images.php'",
356                          "xtype" : "HttpProxy",
357                          "method" : "GET",
358                          "$ xns" : "Roo.data",
359                          "* prop" : "proxy"
360                         },
361                         {
362                          "id" : "id",
363                          "root" : "data",
364                          "xtype" : "JsonReader",
365                          "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"filename\",\"type\":\"string\"},{\"name\":\"url_thumb\",\"type\":\"string\"}]",
366                          "$ xns" : "Roo.data",
367                          "* prop" : "reader",
368                          "totalProperty" : "total"
369                         }
370                        ]
371                       }
372                      ]
373                     },
374                     {
375                      "listeners" : {
376                       "render" : "function (_self)\n{\n    _this.unsubscribeselect = _self;\n}",
377                       "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 }"
378                      },
379                      "alwaysQuery" : true,
380                      "listWidth" : 400,
381                      "triggerAction" : "all",
382                      "fieldLabel" : "Field",
383                      "forceSelection" : true,
384                      "selectOnFocus" : true,
385                      "pageSize" : 20,
386                      "displayField" : "name",
387                      "emptyText" : "Insert Field",
388                      "minChars" : 2,
389                      "valueField" : "type",
390                      "xtype" : "ComboBox",
391                      "typeAhead" : true,
392                      "editable" : false,
393                      "width" : 100,
394                      "$ xns" : "Roo.form",
395                      "* prop" : "btns[]",
396                      "qtip" : "Insert Field",
397                      "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>",
398                      "loadingText" : "Searching...",
399                      "items" : [
400                       {
401                        "xtype" : "SimpleStore",
402                        "$ data" : "[ \n    [ '{person.firstname}', \"First Name\"],\n    [ '{person.lastname}' , \"Last Name\"],\n    [ '{person.name}', \"Full Name\"],\n    [ '#unsubscribe', \"Unsubscribe\"]\n]\n",
403                        "$ fields" : "[  'type', 'name']",
404                        "$ xns" : "Roo.data",
405                        "* prop" : "store"
406                       }
407                      ]
408                     }
409                    ]
410                   }
411                  ]
412                 }
413                ]
414               }
415              ]
416             },
417             {
418              "hideLabels" : true,
419              "xtype" : "Row",
420              "$ xns" : "Roo.form",
421              "items" : [
422               {
423                "listeners" : {
424                 "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}"
425                },
426                "text" : "Convert Html to Text",
427                "xtype" : "Button",
428                "$ xns" : "Roo"
429               }
430              ]
431             },
432             {
433              "hideLabels" : true,
434              "xtype" : "Row",
435              "$ xns" : "Roo.form",
436              "items" : [
437               {
438                "hideLabels" : true,
439                "legend" : "Plain Text",
440                "style" : "text-align:center;",
441                "xtype" : "FieldSet",
442                "$ xns" : "Roo.form",
443                "items" : [
444                 {
445                  "xtype" : "TextArea",
446                  "$ xns" : "Roo.form",
447                  "height" : 50,
448                  "name" : "plaintext"
449                 }
450                ]
451               }
452              ]
453             },
454             {
455              "xtype" : "Hidden",
456              "$ xns" : "Roo.form",
457              "name" : "id"
458             }
459            ]
460           }
461          ]
462         }
463        ]
464       }
465      ]
466     },
467     {
468      "listeners" : {
469       "|activate" : "function() {\n    _this.ipanel = this;\n    if (_this.igrid) {\n       _this.igrid.ds.load({});\n    }\n}"
470      },
471      "autoScroll" : false,
472      "fitToframe" : true,
473      "background" : false,
474      "region" : "east",
475      "title" : "Images / Attachments",
476      "xtype" : "GridPanel",
477      "fitContainer" : true,
478      "$ xns" : "Roo",
479      "tableName" : "Images",
480      "items" : [
481       {
482        "listeners" : {
483         "|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}"
484        },
485        "autoExpandColumn" : "filename",
486        "xtype" : "Grid",
487        "loadMask" : true,
488        "$ xns" : "Roo.grid",
489        "* prop" : "grid",
490        "items" : [
491         {
492          "listeners" : {
493           "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}"
494          },
495          "xtype" : "Store",
496          "remoteSort" : true,
497          "$ sortInfo" : "{ field : 'filename', direction: 'ASC' }",
498          "$ xns" : "Roo.data",
499          "* prop" : "dataSource",
500          "items" : [
501           {
502            "$ url" : "baseURL + '/Roo/Images.php'",
503            "xtype" : "HttpProxy",
504            "method" : "GET",
505            "$ xns" : "Roo.data",
506            "* prop" : "proxy"
507           },
508           {
509            "id" : "id",
510            "root" : "data",
511            "xtype" : "JsonReader",
512            "$ 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]",
513            "$ xns" : "Roo.data",
514            "* prop" : "reader",
515            "totalProperty" : "total"
516           }
517          ]
518         },
519         {
520          "xtype" : "Toolbar",
521          "$ xns" : "Roo",
522          "* prop" : "toolbar",
523          "items" : [
524           {
525            "listeners" : {
526             "|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"
527            },
528            "text" : "Add",
529            "xtype" : "Button",
530            "cls" : "x-btn-text-icon",
531            "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
532            "$ xns" : "Roo.Toolbar"
533           },
534           {
535            "listeners" : {
536             "|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        "
537            },
538            "text" : "Delete",
539            "xtype" : "Button",
540            "cls" : "x-btn-text-icon",
541            "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
542            "$ xns" : "Roo.Toolbar"
543           }
544          ]
545         },
546         {
547          "xtype" : "ColumnModel",
548          "width" : 300,
549          "header" : "Filename",
550          "$ renderer" : "function(v,x,r)\n{\n   return '<img src=\"' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '\" width=\"' + r.data.width + '\" height=\"' + r.data.height + '\" />';\n}",
551          "$ xns" : "Roo.grid",
552          "* prop" : "colModel[]",
553          "dataIndex" : "filename"
554         },
555         {
556          "xtype" : "ColumnModel",
557          "header" : "Displayorder",
558          "width" : 75,
559          "$ renderer" : "function(v) { return String.format('{0}', v); }",
560          "$ xns" : "Roo.grid",
561          "* prop" : "colModel[]",
562          "dataIndex" : "displayorder"
563         },
564         {
565          "xtype" : "ColumnModel",
566          "width" : 75,
567          "header" : "Title",
568          "$ renderer" : "function(v) { return String.format('{0}', v); }",
569          "$ xns" : "Roo.grid",
570          "* prop" : "colModel[]",
571          "dataIndex" : "title"
572         }
573        ]
574       }
575      ]
576     },
577     {
578      "listeners" : {
579       "render" : "function (_self)\n{\n    _this.preview_btn = _self;\n}",
580       "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}"
581      },
582      "text" : "Preview",
583      "xtype" : "Button",
584      "$ xns" : "Roo",
585      "* prop" : "buttons[]"
586     },
587     {
588      "listeners" : {
589       "render" : "function (_self)\n{\n    _this.html_preview = _self;\n}",
590       "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}"
591      },
592      "text" : "Send me a test copy",
593      "xtype" : "Button",
594      "$ xns" : "Roo",
595      "* prop" : "buttons[]"
596     },
597     {
598      "listeners" : {
599       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n}"
600      },
601      "text" : "Cancel",
602      "xtype" : "Button",
603      "$ xns" : "Roo",
604      "* prop" : "buttons[]"
605     },
606     {
607      "listeners" : {
608       "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}"
609      },
610      "text" : "Save",
611      "xtype" : "Button",
612      "$ xns" : "Roo",
613      "* prop" : "buttons[]"
614     }
615    ]
616   }
617  ]
618 }