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