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