Pman.Tab.BAdminEmailTemplates.bjs
[Pman.BAdmin] / Pman.Tab.BAdminEmailTemplates.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.BAdminEmailTemplates = new Roo.XComponent({
8
9  _strings : {
10   'cdb6b6bab1fd18b9dbfe3fb84a5d34ae' :"<i class=\"fa fa-search\"></i>",
11   'cae905999a2ad1dfb8f4eae0e8cda73b' :"From Name<br/>Email",
12   '98d2ee61ddce0c7666297d81639914f1' :"To / BCC Group",
13   '73ea6b4441cdced246d236b22c8f991c' :"HTML File",
14   'cffbd822c38679e2fbf11cc182c945e5' :"search for email template",
15   'b78a3223503896721cca1303f776159b' :"Title",
16   '68b00d723d37122f64da8d9939f836f0' :"BCC Group",
17   '9e11143e29a031212f2cdefcf61f39e9' :"View Message",
18   'f49559cda3fb906fbd7736f8b8a0e37d' :"Email Template",
19   'cd6df251f262cc64514b25f04aecf3c8' :"<i class=\"fa fa-clipboard\"></i> Copy",
20   '27a7146e1e1890e289bc7fad72876831' :"<i class=\"fa fa-plus\"></i> Create a template",
21   'ed807858fcb68abdd180481f1fcba5c5' :"<i class=\"fa fa-trash\"></i> Delete",
22   '4fb044d52809292119086e8733afe9b7' :"<i class=\"fa fa-edit\"></i> Copy",
23   '03c2e7e41ffc181a4e84080b4710e81e' :"New",
24   '49ee3087348e8d44e1feda1917443987' :"Name",
25   'e6b391a8d2c4d45902a23a8b6585703d' :"URL"
26  },
27
28   part     :  ["BAdmin", "EmailTemplates" ],
29   order    : '004-Pman.Tab.BAdminEmailTemplates',
30   region   : 'center',
31   parent   : 'Pman.Tab.BAdmin',
32   name     : "Pman.Tab.BAdminEmailTemplates",
33   disabled : false, 
34   permname : '', 
35   _tree : function(_data)
36   {
37    var _this = this;
38    var MODULE = this;
39    return {
40    xtype : 'Nest',
41    background : true,
42    title : _this._strings['f49559cda3fb906fbd7736f8b8a0e37d'] /* Email Template */,
43    xns : Roo.bootstrap.panel,
44    '|xns' : 'Roo.bootstrap.panel',
45    layout : {
46     xtype : 'Border',
47     xns : Roo.bootstrap.layout,
48     '|xns' : 'Roo.bootstrap.layout',
49     center : {
50      xtype : 'Region',
51      hideTabs : true,
52      tabPosition : 'top',
53      xns : Roo.bootstrap.layout,
54      '|xns' : 'Roo.bootstrap.layout'
55     },
56     south : {
57      xtype : 'Region',
58      autoScroll : true,
59      height : 200,
60      hideTabs : true,
61      split : true,
62      tabPosition : 'top',
63      titlebar : true,
64      xns : Roo.bootstrap.layout,
65      '|xns' : 'Roo.bootstrap.layout'
66     },
67     items  : [
68      {
69       xtype : 'Grid',
70       background : false,
71       closable : false,
72       fitContainer : true,
73       fitToFrame : true,
74       region : 'center',
75       listeners : {
76        activate : function (_self)
77         {
78             _this.edit_btn.hide();
79             _this.copy_btn.hide();
80             _this.delete_btn.hide();
81             
82             if (_this.table) {
83                 _this.table.footer.onClick('first');
84             }
85             
86         },
87        render : function (_self)
88         {
89             _this.grid = this;
90         }
91       },
92       xns : Roo.bootstrap.panel,
93       '|xns' : 'Roo.bootstrap.panel',
94       toolbar : {
95        xtype : 'NavSimplebar',
96        xns : Roo.bootstrap,
97        '|xns' : 'Roo.bootstrap',
98        items  : [
99         {
100          xtype : 'NavGroup',
101          style : 'width: 100%',
102          xns : Roo.bootstrap,
103          '|xns' : 'Roo.bootstrap',
104          items  : [
105           {
106            xtype : 'NavItem',
107            style : 'width: 100%;',
108            xns : Roo.bootstrap,
109            '|xns' : 'Roo.bootstrap',
110            items  : [
111             {
112              xtype : 'Container',
113              style : 'width: 100%;',
114              xns : Roo.bootstrap,
115              '|xns' : 'Roo.bootstrap',
116              items  : [
117               {
118                xtype : 'Row',
119                style : 'padding: 10px;',
120                xns : Roo.bootstrap,
121                '|xns' : 'Roo.bootstrap',
122                items  : [
123                 {
124                  xtype : 'Column',
125                  md : 4,
126                  xns : Roo.bootstrap,
127                  '|xns' : 'Roo.bootstrap',
128                  items  : [
129                   {
130                    xtype : 'Input',
131                    placeholder : _this._strings['cffbd822c38679e2fbf11cc182c945e5'] /* search for email template */,
132                    listeners : {
133                     render : function (_self)
134                      {
135                          _this.searchBox = this;
136                      },
137                     specialkey : function (_self, e)
138                      {
139                          _this.table.footer.onClick('first');
140                      }
141                    },
142                    xns : Roo.bootstrap,
143                    '|xns' : 'Roo.bootstrap',
144                    after : {
145                     xtype : 'Button',
146                     html : _this._strings['cdb6b6bab1fd18b9dbfe3fb84a5d34ae'] /* <i class="fa fa-search"></i> */,
147                     listeners : {
148                      click : function (_self, e)
149                       {
150                           _this.table.footer.onClick('first');
151                       }
152                     },
153                     xns : Roo.bootstrap,
154                     '|xns' : 'Roo.bootstrap'
155                    }
156                   }
157                  ]
158                 },
159                 {
160                  xtype : 'Column',
161                  md : 8,
162                  xns : Roo.bootstrap,
163                  '|xns' : 'Roo.bootstrap',
164                  items  : [
165                   {
166                    xtype : 'Button',
167                    html : _this._strings['ed807858fcb68abdd180481f1fcba5c5'] /* <i class="fa fa-trash"></i> Delete */,
168                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
169                    weight : 'primary',
170                    listeners : {
171                     click : function (_self, e)
172                      {
173                          Pman.genericDelete(_this.grid, 'core_email');
174                      },
175                     render : function (_self)
176                      {
177                          _this.delete_btn = this;
178                          
179                          this.hide();
180                      }
181                    },
182                    xns : Roo.bootstrap,
183                    '|xns' : 'Roo.bootstrap'
184                   },
185                   {
186                    xtype : 'Button',
187                    html : _this._strings['cd6df251f262cc64514b25f04aecf3c8'] /* <i class="fa fa-clipboard"></i> Copy */,
188                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
189                    listeners : {
190                     click : function (_self, e)
191                      {
192                          var sel = _this.grid.grid.selModel.getSelected();
193                          if (!sel) {
194                              Roo.MessageBox.alert("Error", "Select a message to copy");
195                              return;
196                          }
197                          new Pman.Request({
198                              url : baseURL + '/Roo/Core_email',
199                              method : 'POST',
200                              params : {
201                                  id : sel.data.id,
202                                  _make_copy : 1
203                              },
204                              success : function() {
205                                  _this.table.footer.onClick('refresh');
206                              }
207                          });
208                      },
209                     render : function (_self)
210                      {
211                          _this.copy_btn = this;
212                          
213                          this.hide();
214                      }
215                    },
216                    xns : Roo.bootstrap,
217                    '|xns' : 'Roo.bootstrap'
218                   },
219                   {
220                    xtype : 'Button',
221                    html : _this._strings['4fb044d52809292119086e8733afe9b7'] /* <i class="fa fa-edit"></i> Copy */,
222                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
223                    listeners : {
224                     click : function (_self, e)
225                      {
226                          var sel = _this.grid.grid.selModel.getSelected();
227                          if (!sel) {
228                              Roo.MessageBox.alert("Error", "Select a message to copy");
229                              return;
230                          }
231                          new Pman.Request({
232                              url : baseURL + '/Roo/Core_email',
233                              method : 'POST',
234                              params : {
235                                  id : sel.data.id,
236                                  _make_copy : 1
237                              },
238                              success : function() {
239                                  _this.table.footer.onClick('refresh');
240                              }
241                          });
242                      },
243                     render : function (_self)
244                      {
245                          _this.edit_btn = this;
246                          
247                          this.hide();
248                      }
249                    },
250                    xns : Roo.bootstrap,
251                    '|xns' : 'Roo.bootstrap'
252                   },
253                   {
254                    xtype : 'Button',
255                    html : _this._strings['27a7146e1e1890e289bc7fad72876831'] /* <i class="fa fa-plus"></i> Create a template */,
256                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
257                    xns : Roo.bootstrap,
258                    '|xns' : 'Roo.bootstrap',
259                    menu : {
260                     xtype : 'Menu',
261                     xns : Roo.bootstrap,
262                     '|xns' : 'Roo.bootstrap',
263                     items  : [
264                      {
265                       xtype : 'MenuItem',
266                       fa : 'file-o',
267                       html : _this._strings['03c2e7e41ffc181a4e84080b4710e81e'] /* New */,
268                       listeners : {
269                        click : function (_self, e)
270                         {
271                             if (!_this.dialog) {
272                                 return;
273                             }
274                             
275                             _this.dialog.show( { id : 0, module : 'core_email' } , function() {
276                                 _this.table.footer.onClick('first');
277                            });
278                         }
279                       },
280                       xns : Roo.bootstrap,
281                       '|xns' : 'Roo.bootstrap'
282                      },
283                      {
284                       xtype : 'MenuItem',
285                       fa : 'link',
286                       html : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'] /* URL */,
287                       listeners : {
288                        click : function (_self, e)
289                         {
290                             Pman.Dialog.BAdminImportUrl.show(
291                                 {
292                                     target : '/Core/ImportMailMessage.php'
293                                 },
294                             
295                                 function(data) {
296                                     if (data) {
297                                         Pman.Dialog.BAdminEmail.dialog.show();
298                                         Pman.Dialog.BAdminEmail.form.findField('bodytext').setValue(data);
299                                     }
300                                 }
301                             );
302                         }
303                       },
304                       xns : Roo.bootstrap,
305                       '|xns' : 'Roo.bootstrap'
306                      },
307                      {
308                       xtype : 'MenuItem',
309                       fa : 'code',
310                       html : _this._strings['73ea6b4441cdced246d236b22c8f991c'] /* HTML File */,
311                       listeners : {
312                        click : function (_self, e)
313                         {
314                             Pman.Dialog.BAdminImage.show(
315                                 {
316                                     _url : '/Core/ImportMailMessage.php'
317                                 },
318                             
319                                 function(data) {
320                                     if (data) {
321                                         Pman.Dialog.BAdminEmail.dialog.show();
322                                         Pman.Dialog.BAdminEmail.form.findField('bodytext').setValue(data);
323                                     }
324                                 }
325                             );
326                         }
327                       },
328                       xns : Roo.bootstrap,
329                       '|xns' : 'Roo.bootstrap'
330                      }
331                     ]
332                    }
333                   }
334                  ]
335                 }
336                ]
337               }
338              ]
339             }
340            ]
341           }
342          ]
343         }
344        ]
345       },
346       grid : {
347        xtype : 'Table',
348        hover : true,
349        loadMask : true,
350        responsive : true,
351        rowSelection : true,
352        listeners : {
353         render : function (_self)
354          {
355              
356              _this.table = this;
357              
358              _this.dialog = Pman.Dialog.BAdminEmail;
359          },
360         rowdblclick : function (_self, el, rowIndex, e)
361          {
362              if (!_this.dialog) {
363                  return;
364              }
365              
366              //var data = this.getDataSource().getAt(rowIndex).data;
367              var data = _this.table.store.getAt(rowIndex).data;
368              
369              _this.dialog.show( {id : data.id, module : 'core_email'} , function() {
370                  
371                  _this.table.footer.onClick('first');
372              }); 
373          }
374        },
375        xns : Roo.bootstrap,
376        '|xns' : 'Roo.bootstrap',
377        footer : {
378         xtype : 'PagingToolbar',
379         displayInfo : true,
380         pageSize : 25,
381         xns : Roo.bootstrap,
382         '|xns' : 'Roo.bootstrap'
383        },
384        store : {
385         xtype : 'Store',
386         remoteSort : true,
387         sortInfo : {field:'name',direction:'ASC'},
388         listeners : {
389          beforeload : function (_self, options)
390           {
391               options.params = options.params || {};
392               
393               var s = _this.searchBox.getValue();
394               
395               if(s.length){
396                   options.params['search[nameortitle]'] = s;
397               }
398           
399           },
400          load : function (_self, records, options)
401           {
402               _this.copy_btn.hide();
403               _this.delete_btn.hide();
404           }
405         },
406         xns : Roo.data,
407         '|xns' : 'Roo.data',
408         proxy : {
409          xtype : 'HttpProxy',
410          method : 'GET',
411          url : baseURL+'/Roo/Core_email.php',
412          xns : Roo.data,
413          '|xns' : 'Roo.data'
414         },
415         reader : {
416          xtype : 'JsonReader',
417          fields : [
418              {
419                  "name":"name",
420                  "type":"string"
421              },
422              {
423                  "name":"subject",
424                  "type":"string"
425              }
426          ],
427          id : 'id',
428          root : 'data',
429          totalProperty : 'total',
430          xns : Roo.data,
431          '|xns' : 'Roo.data'
432         }
433        },
434        sm : {
435         xtype : 'RowSelectionModel',
436         singleSelect : true,
437         listeners : {
438          afterselectionchange : function (_self)
439           {
440               _this.copy_btn.hide();
441               _this.delete_btn.hide();
442               
443               if (!this.getSelected()) {
444                   _this.viewPanel.setContent("Nothing Selected");
445                   return;
446               }
447               
448               if(this.getSelected().data) {
449                   _this.viewPanel.setContent(this.getSelected().data.bodytext);
450               }
451               
452               _this.copy_btn.show();
453               _this.delete_btn.show();
454               
455           }
456         },
457         xns : Roo.bootstrap.Table,
458         '|xns' : 'Roo.bootstrap.Table'
459        },
460        cm : [
461         {
462          xtype : 'ColumnModel',
463          cursor : 'pointer',
464          dataIndex : 'name',
465          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
466          renderer : function(v,x,r) 
467          { 
468              if(r.data.active * 1 < 1){
469              
470                  return String.format('<span style="font-size:12px;"><s>{0}</s><span>', v ? v : ''); 
471                  
472              }
473              
474              return String.format('<span style="font-size:12px;">{0}<span>', v ? v : ''); 
475          },
476          sortable : true,
477          xs : 3,
478          xns : Roo.grid,
479          '|xns' : 'Roo.grid'
480         },
481         {
482          xtype : 'ColumnModel',
483          cursor : 'pointer',
484          dataIndex : 'subject',
485          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
486          renderer : function(v,x,r) 
487          { 
488              if(r.data.active * 1 < 1){
489                  return String.format('<span style="font-size:12px;"><s>{0}</s></span>', v ? v : ''); 
490              }
491              
492              return String.format('<span style="font-size:12px;">{0}</span>', v ? v : ''); 
493          },
494          sortable : true,
495          xs : 3,
496          xns : Roo.grid,
497          '|xns' : 'Roo.grid'
498         },
499         {
500          xtype : 'ColumnModel',
501          cursor : 'pointer',
502          dataIndex : 'from_email',
503          header : _this._strings['cae905999a2ad1dfb8f4eae0e8cda73b'] /* From Name<br/>Email */,
504          renderer : function(v,x,r)
505          {
506              var from_name = r.data.from_name ? r.data.from_name : '';
507              var from_email = r.data.from_email ? r.data.from_email : '';
508              
509              //var r = from_name + '<br>' + from_email ;
510              if(from_name =='') {
511                  return String.format('<span style="font-size:12px;">{0}</span>', from_email);
512              }
513              return String.format('<span style="font-size:12px;">{0} <br> {1}</span>', from_name, from_email);
514              
515              /*
516              return String.format(
517                  '{0}'+'<'+'{1}'+'>',
518                  r.data.from_name ? r.data.from_name : '',
519                  r.data.from_email ? r.data.from_email : ''
520              );
521              */
522          },
523          xs : 3,
524          xns : Roo.grid,
525          '|xns' : 'Roo.grid'
526         },
527         {
528          xtype : 'ColumnModel',
529          cursor : 'pointer',
530          dataIndex : 'to_group_name',
531          header : _this._strings['98d2ee61ddce0c7666297d81639914f1'] /* To / BCC Group */,
532          renderer : function(v,x,r)
533          { 
534              if(r.data.group_member_count * 1 < 1 && r.data.to_group_name !=''){
535                  return String.format('<span style="font-size:12px;">To: {0} <span class="text-danger">(0)</span> <br>BCC: {1}</span>', r.data.to_group_name ,r.data.bcc_group_name ); 
536              }
537              if(r.data.to_group_name ==''){
538                  return String.format('<span style="font-size:12px;">BCC: {0}</span>', r.data.bcc_group_name ); 
539              }
540          
541              return String.format('<span style="font-size:12px;">To: {0} <br>BCC: {1}</span>', r.data.to_group_name,r.data.bcc_group_name ); 
542          },
543          xs : 3,
544          xns : Roo.grid,
545          '|xns' : 'Roo.grid'
546         },
547         {
548          xtype : 'ColumnModel',
549          cursor : 'pointer',
550          dataIndex : 'bcc_group_name',
551          header : _this._strings['68b00d723d37122f64da8d9939f836f0'] /* BCC Group */,
552          hidden : true,
553          renderer : function(v) { return String.format('{0}', v ? v : ''); },
554          xs : 2,
555          xns : Roo.grid,
556          '|xns' : 'Roo.grid'
557         }
558        ]
559       }
560      },
561      {
562       xtype : 'Content',
563       fitToFrame : true,
564       region : 'south',
565       title : _this._strings['9e11143e29a031212f2cdefcf61f39e9'] /* View Message */,
566       listeners : {
567        render : function (_self)
568         {
569             _this.viewPanel = this;
570         }
571       },
572       xns : Roo.bootstrap.panel,
573       '|xns' : 'Roo.bootstrap.panel'
574      }
575     ]
576    }
577   };  }
578 });