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