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