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