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