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