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