Pman.Tab.AdminEmailTemplates.js
[Pman.Admin] / Pman.Tab.AdminEmailTemplates.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.CoreEmail = new Roo.XComponent({
6     part     :  ["Admin","EmailTemplates"],
7     order    : '999-Pman.Tab.AdminEmailTemplates',
8     region   : 'center',
9     parent   : 'Pman.Tab.Admin',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             region : 'center',
21             title : "Email Template",
22             layout : {
23                 xtype: 'BorderLayout',
24                 xns: Roo,
25                 items : [
26                     {
27                         xtype: 'GridPanel',
28                         xns: Roo,
29                         listeners : {
30                             activate : function() {
31                                 _this.panel = this;
32                                 if (_this.grid) {
33                                     _this.grid.footer.onClick('first');
34                                 }
35                             }
36                         },
37                         background : true,
38                         fitContainer : true,
39                         fitToframe : true,
40                         region : 'center',
41                         tableName : 'core_email',
42                         title : "core_email",
43                         grid : {
44                             xtype: 'Grid',
45                             xns: Roo.grid,
46                             listeners : {
47                                 render : function() 
48                                 {
49                                     _this.grid = this; 
50                                     _this.dialog = Pman.Dialog.CoreEmail;
51                                     if (_this.panel.active) {
52                                        _this.grid.footer.onClick('first');
53                                     }
54                                 },
55                                 rowdblclick : function (_self, rowIndex, e)
56                                 {
57                                     if (!_this.dialog) return;
58                                     var data = this.getDataSource().getAt(rowIndex).data;
59                                     _this.dialog.show( {id : data.id, module : 'core_email'} , function() {
60                                         _this.grid.footer.onClick('first');
61                                     }); 
62                                 },
63                                 rowclick : function (_self, rowIndex, e)
64                                 {
65                                    // _this.grid.ds.load({});
66                                     _this.viewPanel.view.store.load({});
67                                 }
68                             },
69                             autoExpandColumn : 'subject',
70                             loadMask : true,
71                             sm : {
72                                 xtype: 'RowSelectionModel',
73                                 xns: Roo.grid,
74                                 singleSelect : true
75                             },
76                             dataSource : {
77                                 xtype: 'Store',
78                                 xns: Roo.data,
79                                 listeners : {
80                                     beforeload : function (_self, options)
81                                     {
82                                         options.params = options.params || {};
83                                         
84                                         var s = _this.searchBox.getValue();
85                                         
86                                         if(s.length){
87                                             options.params['search[nameortitle]'] = s;
88                                         }
89                                     
90                                     }
91                                 },
92                                 remoteSort : true,
93                                 sortInfo : { field : 'id', direction: 'DESC' },
94                                 proxy : {
95                                     xtype: 'HttpProxy',
96                                     xns: Roo.data,
97                                     method : 'GET',
98                                     url : baseURL + '/Roo/Core_email.php'
99                                 },
100                                 reader : {
101                                     xtype: 'JsonReader',
102                                     xns: Roo.data,
103                                     id : 'id',
104                                     root : 'data',
105                                     totalProperty : 'total',
106                                     fields : [
107                                         {
108                                             "name":"name",
109                                             "type":"string"
110                                         },
111                                         {
112                                             "name":"subject",
113                                             "type":"string"
114                                         }
115                                     ]
116                                 }
117                             },
118                             footer : {
119                                 xtype: 'PagingToolbar',
120                                 xns: Roo,
121                                 displayInfo : true,
122                                 displayMsg : "Displaying Message{0} - {1} of {2}",
123                                 emptyMsg : "Nothing found",
124                                 pageSize : 25
125                             },
126                             toolbar : {
127                                 xtype: 'Toolbar',
128                                 xns: Roo,
129                                 items : [
130                                     {
131                                         xtype: 'TextField',
132                                         xns: Roo.form,
133                                         listeners : {
134                                             specialkey : function (_self, e)
135                                             {
136                                               _this.grid.footer.onClick('first');
137                                             },
138                                             render : function (_self)
139                                             {
140                                                 _this.searchBox = _self;
141                                             }
142                                         }
143                                     },
144                                     {
145                                         xtype: 'Button',
146                                         xns: Roo.Toolbar,
147                                         listeners : {
148                                             click : function (_self, e)
149                                             {
150                                                 _this.grid.footer.onClick('first');
151                                             }
152                                         },
153                                         cls : 'x-btn-icon',
154                                         icon : rootURL + '/Pman/templates/images/search.gif'
155                                     },
156                                     {
157                                         xtype: 'Button',
158                                         xns: Roo.Toolbar,
159                                         listeners : {
160                                             click : function (_self, e)
161                                             {
162                                                 _this.searchBox.setValue('');
163                                                 _this.grid.footer.onClick('first');
164                                             }
165                                         },
166                                         cls : 'x-btn-icon',
167                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif'
168                                     },
169                                     {
170                                         xtype: 'Fill',
171                                         xns: Roo.Toolbar
172                                     },
173                                     {
174                                         xtype: 'Button',
175                                         xns: Roo.Toolbar,
176                                         listeners : {
177                                             click : function()
178                                             {
179                                               var sel = _this.grid.selModel.getSelected();
180                                               if (!sel) {
181                                                     Roo.MessageBox.alert("Error", "Select a message to copy");
182                                                     return;
183                                                 }
184                                             new Pman.Request({
185                                                 url : baseURL + '/Roo/Core_email',
186                                                 method : 'POST',
187                                                 params : {
188                                                     id : sel.data.id,
189                                                     _make_copy : 1
190                                                 },
191                                                 success : function() {
192                                                     _this.grid.footer.onClick('refresh');
193                                                 }
194                                             });
195                                               
196                                             }
197                                         },
198                                         cls : 'x-btn-text-icon',
199                                         text : "Copy",
200                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
201                                     },
202                                     {
203                                         xtype: 'Button',
204                                         xns: Roo.Toolbar,
205                                         listeners : {
206                                             click : function()
207                                             {
208                                                 if (!_this.dialog) return;
209                                                 _this.dialog.show( { id : 0, module : 'core_email' } , function() {
210                                                     _this.grid.footer.onClick('first');
211                                                }); 
212                                             }
213                                         },
214                                         cls : 'x-btn-text-icon',
215                                         text : "Add",
216                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
217                                     },
218                                     {
219                                         xtype: 'Separator',
220                                         xns: Roo.Toolbar
221                                     },
222                                     {
223                                         xtype: 'Button',
224                                         xns: Roo.Toolbar,
225                                         listeners : {
226                                             click : function()
227                                             {
228                                                 Pman.genericDelete(_this, 'core_email');
229                                                 
230                                             }
231                                         },
232                                         cls : 'x-btn-text-icon',
233                                         text : "Delete",
234                                         icon : rootURL + '/Pman/templates/images/trash.gif'
235                                     }
236                                 ]
237                             },
238                             colModel : [
239                                 {
240                                     xtype: 'ColumnModel',
241                                     xns: Roo.grid,
242                                     dataIndex : 'name',
243                                     header : 'Name',
244                                     width : 250,
245                                     renderer : function(v) { return String.format('{0}', v); }
246                                 },
247                                 {
248                                     xtype: 'ColumnModel',
249                                     xns: Roo.grid,
250                                     dataIndex : 'subject',
251                                     header : 'Title',
252                                     width : 300,
253                                     renderer : function(v) { return String.format('{0}', v); }
254                                 },
255                                 {
256                                     xtype: 'ColumnModel',
257                                     xns: Roo.grid,
258                                     dataIndex : 'from_name',
259                                     header : 'From Name',
260                                     width : 400,
261                                     renderer : function(v) { return String.format('{0}', v); }
262                                 },
263                                 {
264                                     xtype: 'ColumnModel',
265                                     xns: Roo.grid,
266                                     dataIndex : 'from_email',
267                                     header : 'From Email',
268                                     width : 400,
269                                     renderer : function(v) { return String.format('{0}', v); }
270                                 }
271                             ]
272                         }
273                     },
274                     {
275                         xtype: 'ContentPanel',
276                         xns: Roo,
277                         listeners : {
278                             render : function (_self)
279                             {
280                                 _this.viewPanel = _self;
281                             }
282                         },
283                         autoScroll : true,
284                         background : false,
285                         fitContainer : true,
286                         fitToFrame : true,
287                         region : 'south',
288                         title : "View Message",
289                         view : {
290                             xtype: 'View',
291                             xns: Roo,
292                             listeners : {
293                                 preparedata : function (_self, data, i, rec)
294                                 {
295                                    // Roo.log(data);
296                                     //Roo.apply(data, rec.json);
297                                 }
298                             },
299                             tpl : new Roo.DomTemplate({url : rootURL+'/Pman/Crm/domtemplates/crm_mail.html'}),
300                             store : {
301                                 xtype: 'Store',
302                                 xns: Roo.data,
303                                 listeners : {
304                                     beforeload : function (_self, options)
305                                     {
306                                         options.params = options.params || {};
307                                         var p = _this.grid.selModel.getSelected();
308                                         if (!p || !p.data.id) {
309                                             this.removeAll();
310                                             return false;
311                                         }
312                                        
313                                         options.params['id'] = p.data.id;
314                                      
315                                     },
316                                     load : function (_self, records, options)
317                                     {
318                                         var p = _this.grid.selModel.getSelected();
319                                       //  Roo.log(p);
320                                         if (!p || !p.data.id) {
321                                             this.removeAll();
322                                             return false;
323                                         }
324                                       /*  
325                                         new Pman.Request({
326                                             url : baseURL + '/Roo/crm_action.php',
327                                             method : 'GET',
328                                             params : {
329                                                 person_id : p.data.id,
330                                                 sort : 'action_dt',
331                                                 dir : 'DESC'
332                                             },
333                                             success : function(res) {
334                                                 if(res.success){
335                                                     var el = _this.cpanel.el.select('.crm-history-content').first();
336                                                     _this.historyTemplate.overwrite(el, res);
337                                                     el.select('.crm-history-log').on('click', Pman.Crm.auditToggle);
338                                                     //Roo.log(res);
339                                                 }
340                                             },
341                                             failure : function(e) {
342                                                 //Roo.log(e);
343                                               _this.grid.ds.load({});
344                                             }
345                                             
346                                         });
347                                         */
348                                     
349                                     //_this.historyTemplate = new Roo.DomTemplate({url : rootURL+'/Pman/Crm/domtemplates/crm_history.html'})
350                                     
351                                     /*
352                                       new pman request ([
353                                       
354                                       } successs(data)
355                                            el = _this.elemmnt.select('.services')
356                                            _this.serviceTemplate.overwite(el, data)
357                                       */
358                                     }
359                                 },
360                                 proxy : {
361                                     xtype: 'HttpProxy',
362                                     xns: Roo.data,
363                                     method : 'GET',
364                                     url : baseURL+'/Roo/Core_email.php'
365                                 },
366                                 reader : {
367                                     xtype: 'JsonReader',
368                                     xns: Roo.data,
369                                     id : 'id',
370                                     root : 'data',
371                                     totalProperty : 'total'
372                                 }
373                             }
374                         }
375                     }
376                 ],
377                 center : {
378                     xtype: 'LayoutRegion',
379                     xns: Roo,
380                     autoScroll : false,
381                     split : true
382                 },
383                 south : {
384                     xtype: 'LayoutRegion',
385                     xns: Roo,
386                     autoScroll : false,
387                     height : 300,
388                     split : true,
389                     titlebar : true
390                 }
391             }
392         };
393     }
394 });