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) { return String.format('{0}', v); },
325          sortable : true,
326          width : 250,
327          xns : Roo.grid,
328          '|xns' : 'Roo.grid',
329          xtype : 'ColumnModel'
330         },
331         {
332          dataIndex : 'subject',
333          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
334          renderer : function(v) { return String.format('{0}', v); },
335          sortable : true,
336          width : 300,
337          xns : Roo.grid,
338          '|xns' : 'Roo.grid',
339          xtype : 'ColumnModel'
340         },
341         {
342          dataIndex : 'from_name',
343          header : _this._strings['4a4a8fe0c6dfb6bd2a41755d15eb6f0b'] /* From Name */,
344          renderer : function(v) { return String.format('{0}', v); },
345          sortable : true,
346          width : 400,
347          xns : Roo.grid,
348          '|xns' : 'Roo.grid',
349          xtype : 'ColumnModel'
350         },
351         {
352          dataIndex : 'from_email',
353          header : _this._strings['4ca679a383343ab3d4ca1cd7c91b43f7'] /* From Email */,
354          renderer : function(v) { return String.format('{0}', v); },
355          sortable : true,
356          width : 400,
357          xns : Roo.grid,
358          '|xns' : 'Roo.grid',
359          xtype : 'ColumnModel'
360         },
361         {
362          dataIndex : 'bcc_group_name',
363          header : _this._strings['68b00d723d37122f64da8d9939f836f0'] /* BCC Group */,
364          renderer : function(v) { return String.format('{0}', v ? v : ''); },
365          sortable : true,
366          width : 400,
367          xns : Roo.grid,
368          '|xns' : 'Roo.grid',
369          xtype : 'ColumnModel'
370         }
371        ]
372       }
373      },
374      {
375       autoScroll : true,
376       background : false,
377       fitContainer : true,
378       fitToFrame : true,
379       region : 'south',
380       title : _this._strings['9e11143e29a031212f2cdefcf61f39e9'] /* View Message */,
381       xns : Roo,
382       '|xns' : 'Roo',
383       xtype : 'ContentPanel',
384       listeners : {
385        render : function (_self)
386         {
387             _this.viewPanel = _self;
388         }
389       },
390       view : {
391        tpl : new Roo.DomTemplate({url : rootURL+'/Pman/Crm/domtemplates/crm_mail.html'}),
392        xns : Roo,
393        '|xns' : 'Roo',
394        xtype : 'View',
395        listeners : {
396         preparedata : function (_self, data, i, rec)
397          {
398             // Roo.log(data);
399              //Roo.apply(data, rec.json);
400          }
401        },
402        store : {
403         xns : Roo.data,
404         '|xns' : 'Roo.data',
405         xtype : 'Store',
406         listeners : {
407          beforeload : function (_self, options)
408           {
409               options.params = options.params || {};
410               var p = _this.grid.selModel.getSelected();
411               if (!p || !p.data.id) {
412                   this.removeAll();
413                   return false;
414               }
415              
416               options.params['id'] = p.data.id;
417            
418           },
419          load : function (_self, records, options)
420           {
421               var p = _this.grid.selModel.getSelected();
422             //  Roo.log(p);
423               if (!p || !p.data.id) {
424                   this.removeAll();
425                   return false;
426               }
427             /*  
428               new Pman.Request({
429                   url : baseURL + '/Roo/crm_action.php',
430                   method : 'GET',
431                   params : {
432                       person_id : p.data.id,
433                       sort : 'action_dt',
434                       dir : 'DESC'
435                   },
436                   success : function(res) {
437                       if(res.success){
438                           var el = _this.cpanel.el.select('.crm-history-content').first();
439                           _this.historyTemplate.overwrite(el, res);
440                           el.select('.crm-history-log').on('click', Pman.Crm.auditToggle);
441                           //Roo.log(res);
442                       }
443                   },
444                   failure : function(e) {
445                       //Roo.log(e);
446                     _this.grid.ds.load({});
447                   }
448                   
449               });
450               */
451           
452           //_this.historyTemplate = new Roo.DomTemplate({url : rootURL+'/Pman/Crm/domtemplates/crm_history.html'})
453           
454           /*
455             new pman request ([
456             
457             } successs(data)
458                  el = _this.elemmnt.select('.services')
459                  _this.serviceTemplate.overwite(el, data)
460             */
461           }
462         },
463         proxy : {
464          method : 'GET',
465          url : baseURL+'/Roo/Core_email.php',
466          xns : Roo.data,
467          '|xns' : 'Roo.data',
468          xtype : 'HttpProxy'
469         },
470         reader : {
471          id : 'id',
472          root : 'data',
473          totalProperty : 'total',
474          xns : Roo.data,
475          '|xns' : 'Roo.data',
476          xtype : 'JsonReader'
477         }
478        }
479       }
480      }
481     ]
482    }
483   };  }
484 });