tidy up listing of email templates
[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 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.AdminEmailTemplates = new Roo.XComponent({
8
9  _strings : {
10   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
11   'c7d299bf3f9e37c77ab646f7e5366696' :"core_email",
12   '00d6e06d2f3c092b4f5e1e708a360b0f' :"Displaying Message{0} - {1} of {2}",
13   '9076cbba1d9ef79280b4f39e2aa0d115' :"Nothing found",
14   'b78a3223503896721cca1303f776159b' :"Title",
15   '68b00d723d37122f64da8d9939f836f0' :"BCC Group",
16   '9e11143e29a031212f2cdefcf61f39e9' :"View Message",
17   'f49559cda3fb906fbd7736f8b8a0e37d' :"Email Template",
18   '01bd6a16732dfa2b760dc8566c58afae' :"Download to Excel",
19   '4a4a8fe0c6dfb6bd2a41755d15eb6f0b' :"From Name",
20   '4ca679a383343ab3d4ca1cd7c91b43f7' :"From Email",
21   '5fb63579fc981698f97d55bfecb213ea' :"Copy",
22   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
23   '49ee3087348e8d44e1feda1917443987' :"Name"
24  },
25
26   part     :  ["Admin", "EmailTemplates" ],
27   order    : '999-Pman.Tab.AdminEmailTemplates',
28   region   : 'center',
29   parent   : 'Pman.Tab.Admin',
30   name     : "Manage Email Templates",
31   disabled : false, 
32   permname : '', 
33   _tree : function(_data)
34   {
35    var _this = this;
36    var MODULE = this;
37    return {
38    xtype : 'NestedLayoutPanel',
39    region : 'center',
40    title : _this._strings['f49559cda3fb906fbd7736f8b8a0e37d'] /* Email Template */,
41    listeners : {
42     render : function (_self)
43      {
44          _this.nest = this;
45      }
46    },
47    xns : Roo,
48    '|xns' : 'Roo',
49    layout : {
50     xtype : 'BorderLayout',
51     xns : Roo,
52     '|xns' : 'Roo',
53     center : {
54      xtype : 'LayoutRegion',
55      autoScroll : false,
56      split : true,
57      xns : Roo,
58      '|xns' : 'Roo'
59     },
60     south : {
61      xtype : 'LayoutRegion',
62      autoScroll : false,
63      height : 300,
64      split : true,
65      titlebar : true,
66      xns : Roo,
67      '|xns' : 'Roo'
68     },
69     items  : [
70      {
71       xtype : 'GridPanel',
72       background : true,
73       fitContainer : true,
74       fitToframe : true,
75       region : 'center',
76       tableName : 'core_email',
77       title : _this._strings['c7d299bf3f9e37c77ab646f7e5366696'] /* core_email */,
78       listeners : {
79        activate : function() {
80             _this.panel = this;
81             if (_this.grid) {
82                 _this.grid.footer.onClick('first');
83             }
84         }
85       },
86       xns : Roo,
87       '|xns' : 'Roo',
88       grid : {
89        xtype : 'Grid',
90        autoExpandColumn : 'subject',
91        loadMask : true,
92        listeners : {
93         render : function() 
94          {
95              _this.grid = this; 
96              _this.dialog = Pman.Dialog.CoreEmail;
97              if (_this.panel.active) {
98                 _this.grid.footer.onClick('first');
99              }
100          },
101         rowclick : function (_self, rowIndex, e)
102          {
103             // _this.grid.ds.load({});
104              _this.viewPanel.view.store.load({});
105          },
106         rowdblclick : function (_self, rowIndex, e)
107          {
108              if (!_this.dialog) { 
109                  return;
110                  }
111              var data = this.getDataSource().getAt(rowIndex).data;
112              _this.dialog.show( {id : data.id, module : 'core_email'} , function() {
113                  _this.grid.footer.onClick('first');
114              }); 
115          }
116        },
117        xns : Roo.grid,
118        '|xns' : 'Roo.grid',
119        footer : {
120         xtype : 'PagingToolbar',
121         displayInfo : true,
122         displayMsg : _this._strings['00d6e06d2f3c092b4f5e1e708a360b0f'] /* Displaying Message{0} - {1} of {2} */,
123         emptyMsg : _this._strings['9076cbba1d9ef79280b4f39e2aa0d115'] /* Nothing found */,
124         pageSize : 25,
125         xns : Roo,
126         '|xns' : 'Roo',
127         items  : [
128          {
129           xtype : 'Button',
130           text : _this._strings['01bd6a16732dfa2b760dc8566c58afae'] /* Download to Excel */,
131           listeners : {
132            click : function()
133             {
134                
135             new Pman.Download({
136                 url : baseURL + '/Roo/Core_email',
137                 method : 'GET',
138                 params : {
139                     csvCols : '*',
140                     csvTitles : '*'
141                 }
142             });
143             Roo.MessageBox.alert("Notice", "Should be downloading now");
144               
145             }
146           },
147           xns : Roo.Toolbar,
148           '|xns' : 'Roo.Toolbar'
149          }
150         ]
151        },
152        toolbar : {
153         xtype : 'Toolbar',
154         xns : Roo,
155         '|xns' : 'Roo',
156         items  : [
157          {
158           xtype : 'TextField',
159           listeners : {
160            render : function (_self)
161             {
162                 _this.searchBox = _self;
163             },
164            specialkey : function (_self, e)
165             {
166               _this.grid.footer.onClick('first');
167             }
168           },
169           xns : Roo.form,
170           '|xns' : 'Roo.form'
171          },
172          {
173           xtype : 'Button',
174           cls : 'x-btn-icon',
175           icon : rootURL + '/Pman/templates/images/search.gif',
176           listeners : {
177            click : function (_self, e)
178             {
179                 _this.grid.footer.onClick('first');
180             }
181           },
182           xns : Roo.Toolbar,
183           '|xns' : 'Roo.Toolbar'
184          },
185          {
186           xtype : 'Button',
187           cls : 'x-btn-icon',
188           icon : rootURL + '/Pman/templates/images/edit-clear.gif',
189           listeners : {
190            click : function (_self, e)
191             {
192                 _this.searchBox.setValue('');\r
193                 _this.grid.footer.onClick('first');\r
194             }
195           },
196           xns : Roo.Toolbar,
197           '|xns' : 'Roo.Toolbar'
198          },
199          {
200           xtype : 'Fill',
201           xns : Roo.Toolbar,
202           '|xns' : 'Roo.Toolbar'
203          },
204          {
205           xtype : 'Button',
206           cls : 'x-btn-text-icon',
207           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
208           text : _this._strings['5fb63579fc981698f97d55bfecb213ea'] /* Copy */,
209           listeners : {
210            click : function()
211             {
212               var sel = _this.grid.selModel.getSelected();
213               if (!sel) {
214                     Roo.MessageBox.alert("Error", "Select a message to copy");
215                     return;
216                 }
217             new Pman.Request({
218                 url : baseURL + '/Roo/Core_email',
219                 method : 'POST',
220                 params : {
221                     id : sel.data.id,
222                     _make_copy : 1
223                 },
224                 success : function() {
225                     _this.grid.footer.onClick('refresh');
226                 }
227             });
228               
229             }
230           },
231           xns : Roo.Toolbar,
232           '|xns' : 'Roo.Toolbar'
233          },
234          {
235           xtype : 'Button',
236           cls : 'x-btn-text-icon',
237           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
238           text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
239           listeners : {
240            click : function()
241             {
242                 if (!_this.dialog) {
243                      return;
244                      }
245                 _this.dialog.show( { id : 0, module : 'core_email' } , function() {
246                     _this.grid.footer.onClick('first');
247                }); 
248             }
249           },
250           xns : Roo.Toolbar,
251           '|xns' : 'Roo.Toolbar'
252          },
253          {
254           xtype : 'Separator',
255           xns : Roo.Toolbar,
256           '|xns' : 'Roo.Toolbar'
257          },
258          {
259           xtype : 'Button',
260           cls : 'x-btn-text-icon',
261           icon : rootURL + '/Pman/templates/images/trash.gif',
262           text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
263           listeners : {
264            click : function()
265             {
266                 Pman.genericDelete(_this, 'core_email');
267                 
268             }
269           },
270           xns : Roo.Toolbar,
271           '|xns' : 'Roo.Toolbar'
272          }
273         ]
274        },
275        dataSource : {
276         xtype : 'Store',
277         remoteSort : true,
278         sortInfo : { field : 'description', direction: 'ASC' },
279         listeners : {
280          beforeload : function (_self, options)
281           {
282               options.params = options.params || {};
283               
284               var s = _this.searchBox.getValue();
285               
286               if(s.length){
287                   options.params['search[nameortitle]'] = s;
288               }
289           
290           }
291         },
292         xns : Roo.data,
293         '|xns' : 'Roo.data',
294         proxy : {
295          xtype : 'HttpProxy',
296          method : 'GET',
297          url : baseURL + '/Roo/Core_email.php',
298          xns : Roo.data,
299          '|xns' : 'Roo.data'
300         },
301         reader : {
302          xtype : 'JsonReader',
303          fields : [
304              {
305                  "name":"name",
306                  "type":"string"
307              },
308              {
309                  "name":"subject",
310                  "type":"string"
311              }
312          ],
313          id : 'id',
314          root : 'data',
315          totalProperty : 'total',
316          xns : Roo.data,
317          '|xns' : 'Roo.data'
318         }
319        },
320        sm : {
321         xtype : 'RowSelectionModel',
322         singleSelect : true,
323         xns : Roo.grid,
324         '|xns' : 'Roo.grid'
325        },
326        cm : [
327         {
328          xtype : 'ColumnModel',
329          dataIndex : 'name',
330          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
331          renderer : function(v,x,r) 
332          { 
333              if (r.data.description.length > 0) {
334                  v = r.data.description;
335              }
336              
337              
338              if(r.data.active * 1 < 1){
339                  return String.format('<s>{0}</s>', v ? v : ''); 
340              }
341              
342              return String.format('{0}', v ? v : ''); 
343          },
344          sortable : true,
345          width : 250,
346          xns : Roo.grid,
347          '|xns' : 'Roo.grid'
348         },
349         {
350          xtype : 'ColumnModel',
351          dataIndex : 'subject',
352          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
353          renderer : function(v,x,r) 
354          { 
355              if(r.data.active * 1 < 1){
356                  return String.format('<s>{0}</s>', v ? v : ''); 
357              }
358              
359              return String.format('{0}', v ? v : ''); 
360          },
361          sortable : true,
362          width : 300,
363          xns : Roo.grid,
364          '|xns' : 'Roo.grid'
365         },
366         {
367          xtype : 'ColumnModel',
368          dataIndex : 'from_name',
369          header : _this._strings['4a4a8fe0c6dfb6bd2a41755d15eb6f0b'] /* From Name */,
370          renderer : function(v) { return String.format('{0}', v ? v : ''); },
371          sortable : true,
372          width : 150,
373          xns : Roo.grid,
374          '|xns' : 'Roo.grid'
375         },
376         {
377          xtype : 'ColumnModel',
378          dataIndex : 'from_email',
379          header : _this._strings['4ca679a383343ab3d4ca1cd7c91b43f7'] /* From Email */,
380          renderer : function(v) { return String.format('{0}', v ? v : ''); },
381          sortable : true,
382          width : 150,
383          xns : Roo.grid,
384          '|xns' : 'Roo.grid'
385         },
386         {
387          xtype : 'ColumnModel',
388          dataIndex : 'bcc_group_name',
389          header : _this._strings['68b00d723d37122f64da8d9939f836f0'] /* BCC Group */,
390          renderer : function(v) { return String.format('{0}', v ? v : ''); },
391          sortable : true,
392          width : 150,
393          xns : Roo.grid,
394          '|xns' : 'Roo.grid'
395         }
396        ]
397       }
398      },
399      {
400       xtype : 'ContentPanel',
401       autoScroll : true,
402       background : false,
403       fitContainer : true,
404       fitToFrame : true,
405       region : 'south',
406       title : _this._strings['9e11143e29a031212f2cdefcf61f39e9'] /* View Message */,
407       listeners : {
408        render : function (_self)
409         {
410             _this.viewPanel = _self;
411         }
412       },
413       xns : Roo,
414       '|xns' : 'Roo',
415       view : {
416        xtype : 'View',
417        tpl : new Roo.DomTemplate({url : rootURL+'/Pman/Crm/domtemplates/crm_mail.html'}),
418        listeners : {
419         preparedata : function (_self, data, i, rec)
420          {
421             // Roo.log(data);
422              //Roo.apply(data, rec.json);
423          }
424        },
425        xns : Roo,
426        '|xns' : 'Roo',
427        store : {
428         xtype : 'Store',
429         listeners : {
430          beforeload : function (_self, options)
431           {
432               options.params = options.params || {};
433               var p = _this.grid.selModel.getSelected();
434               if (!p || !p.data.id) {
435                   this.removeAll();
436                   return false;
437               }
438              
439               options.params['id'] = p.data.id;
440            
441           },
442          load : function (_self, records, options)
443           {
444               var p = _this.grid.selModel.getSelected();
445             //  Roo.log(p);
446               if (!p || !p.data.id) {
447                   this.removeAll();
448                   return false;
449               }
450             /*  
451               new Pman.Request({
452                   url : baseURL + '/Roo/crm_action.php',
453                   method : 'GET',
454                   params : {
455                       person_id : p.data.id,
456                       sort : 'action_dt',
457                       dir : 'DESC'
458                   },
459                   success : function(res) {
460                       if(res.success){
461                           var el = _this.cpanel.el.select('.crm-history-content').first();
462                           _this.historyTemplate.overwrite(el, res);
463                           el.select('.crm-history-log').on('click', Pman.Crm.auditToggle);
464                           //Roo.log(res);
465                       }
466                   },
467                   failure : function(e) {
468                       //Roo.log(e);
469                     _this.grid.ds.load({});
470                   }
471                   
472               });
473               */
474           
475           //_this.historyTemplate = new Roo.DomTemplate({url : rootURL+'/Pman/Crm/domtemplates/crm_history.html'})
476           
477           /*
478             new pman request ([
479             
480             } successs(data)
481                  el = _this.elemmnt.select('.services')
482                  _this.serviceTemplate.overwite(el, data)
483             */
484           }
485         },
486         xns : Roo.data,
487         '|xns' : 'Roo.data',
488         proxy : {
489          xtype : 'HttpProxy',
490          method : 'GET',
491          url : baseURL+'/Roo/Core_email.php',
492          xns : Roo.data,
493          '|xns' : 'Roo.data'
494         },
495         reader : {
496          xtype : 'JsonReader',
497          id : 'id',
498          root : 'data',
499          totalProperty : 'total',
500          xns : Roo.data,
501          '|xns' : 'Roo.data'
502         }
503        }
504       }
505      }
506     ]
507    }
508   };  }
509 });