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