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   '694e249c3a9503141fa5ce3fb71d5477' :"<i class=\"fa fa-edit\"></i> Edit",
14   '73ea6b4441cdced246d236b22c8f991c' :"HTML File",
15   'cffbd822c38679e2fbf11cc182c945e5' :"search for email template",
16   'b78a3223503896721cca1303f776159b' :"Title",
17   '68b00d723d37122f64da8d9939f836f0' :"BCC Group",
18   '9e11143e29a031212f2cdefcf61f39e9' :"View Message",
19   'f49559cda3fb906fbd7736f8b8a0e37d' :"Email Template",
20   'cd6df251f262cc64514b25f04aecf3c8' :"<i class=\"fa fa-clipboard\"></i> Copy",
21   '27a7146e1e1890e289bc7fad72876831' :"<i class=\"fa fa-plus\"></i> Create a template",
22   'ed807858fcb68abdd180481f1fcba5c5' :"<i class=\"fa fa-trash\"></i> Delete",
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          xns : Roo.bootstrap,
102          '|xns' : 'Roo.bootstrap',
103          items  : [
104           {
105            xtype : 'NavItem',
106            style : 'width: 100%;',
107            xns : Roo.bootstrap,
108            '|xns' : 'Roo.bootstrap',
109            items  : [
110             {
111              xtype : 'Container',
112              style : 'width: 100%;',
113              xns : Roo.bootstrap,
114              '|xns' : 'Roo.bootstrap',
115              items  : [
116               {
117                xtype : 'Row',
118                style : 'padding: 10px;',
119                xns : Roo.bootstrap,
120                '|xns' : 'Roo.bootstrap',
121                items  : [
122                 {
123                  xtype : 'Column',
124                  md : 4,
125                  xns : Roo.bootstrap,
126                  '|xns' : 'Roo.bootstrap',
127                  items  : [
128                   {
129                    xtype : 'Input',
130                    placeholder : _this._strings['cffbd822c38679e2fbf11cc182c945e5'] /* search for email template */,
131                    listeners : {
132                     render : function (_self)
133                      {
134                          _this.searchBox = this;
135                      },
136                     specialkey : function (_self, e)
137                      {
138                          _this.table.footer.onClick('first');
139                      }
140                    },
141                    xns : Roo.bootstrap,
142                    '|xns' : 'Roo.bootstrap',
143                    after : {
144                     xtype : 'Button',
145                     html : _this._strings['cdb6b6bab1fd18b9dbfe3fb84a5d34ae'] /* <i class="fa fa-search"></i> */,
146                     listeners : {
147                      click : function (_self, e)
148                       {
149                           _this.table.footer.onClick('first');
150                       }
151                     },
152                     xns : Roo.bootstrap,
153                     '|xns' : 'Roo.bootstrap'
154                    }
155                   }
156                  ]
157                 },
158                 {
159                  xtype : 'Column',
160                  md : 8,
161                  xns : Roo.bootstrap,
162                  '|xns' : 'Roo.bootstrap',
163                  items  : [
164                   {
165                    xtype : 'Button',
166                    html : _this._strings['ed807858fcb68abdd180481f1fcba5c5'] /* <i class="fa fa-trash"></i> Delete */,
167                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
168                    weight : 'primary',
169                    listeners : {
170                     click : function (_self, e)
171                      {
172                          Pman.genericDelete(_this.grid, 'core_email');
173                      },
174                     render : function (_self)
175                      {
176                          _this.delete_btn = this;
177                          
178                          this.hide();
179                      }
180                    },
181                    xns : Roo.bootstrap,
182                    '|xns' : 'Roo.bootstrap'
183                   },
184                   {
185                    xtype : 'Button',
186                    html : _this._strings['cd6df251f262cc64514b25f04aecf3c8'] /* <i class="fa fa-clipboard"></i> Copy */,
187                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
188                    listeners : {
189                     click : function (_self, e)
190                      {
191                          var sel = _this.grid.grid.selModel.getSelected();
192                          if (!sel) {
193                              Roo.MessageBox.alert("Error", "Select a message to copy");
194                              return;
195                          }
196                          new Pman.Request({
197                              url : baseURL + '/Roo/Core_email',
198                              method : 'POST',
199                              params : {
200                                  id : sel.data.id,
201                                  _make_copy : 1
202                              },
203                              success : function() {
204                                  _this.table.footer.onClick('refresh');
205                              }
206                          });
207                      },
208                     render : function (_self)
209                      {
210                          _this.copy_btn = this;
211                          
212                          this.hide();
213                      }
214                    },
215                    xns : Roo.bootstrap,
216                    '|xns' : 'Roo.bootstrap'
217                   },
218                   {
219                    xtype : 'Button',
220                    html : _this._strings['694e249c3a9503141fa5ce3fb71d5477'] /* <i class="fa fa-edit"></i> Edit */,
221                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
222                    listeners : {
223                     click : function (_self, e)
224                      {
225                          var sel = _this.grid.grid.selModel.getSelected();
226                          
227                          if (!sel || sel.data.id * 1 < 1) {
228                              Roo.MessageBox.alert("Error", "Select a message to edit");
229                              return;
230                          }
231                          
232                          Pman.Dialog.BAdminEmail.show( {id : sel.data.id, module : 'core_email'} , function() {
233                              _this.table.footer.onClick('first');
234                          }); 
235                      },
236                     render : function (_self)
237                      {
238                          _this.edit_btn = this;
239                          
240                          this.hide();
241                      }
242                    },
243                    xns : Roo.bootstrap,
244                    '|xns' : 'Roo.bootstrap'
245                   },
246                   {
247                    xtype : 'Button',
248                    html : _this._strings['27a7146e1e1890e289bc7fad72876831'] /* <i class="fa fa-plus"></i> Create a template */,
249                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
250                    xns : Roo.bootstrap,
251                    '|xns' : 'Roo.bootstrap',
252                    menu : {
253                     xtype : 'Menu',
254                     xns : Roo.bootstrap,
255                     '|xns' : 'Roo.bootstrap',
256                     items  : [
257                      {
258                       xtype : 'MenuItem',
259                       fa : 'file-o',
260                       html : _this._strings['03c2e7e41ffc181a4e84080b4710e81e'] /* New */,
261                       listeners : {
262                        click : function (_self, e)
263                         {
264                             if (!_this.dialog) {
265                                 return;
266                             }
267                             
268                             _this.dialog.show( { id : 0, module : 'core_email' } , function() {
269                                 _this.table.footer.onClick('first');
270                            });
271                         }
272                       },
273                       xns : Roo.bootstrap,
274                       '|xns' : 'Roo.bootstrap'
275                      },
276                      {
277                       xtype : 'MenuItem',
278                       fa : 'link',
279                       html : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'] /* URL */,
280                       listeners : {
281                        click : function (_self, e)
282                         {
283                             Pman.Dialog.BAdminImportUrl.show(
284                                 {
285                                     target : '/Core/ImportMailMessage.php'
286                                 },
287                             
288                                 function(data) {
289                                     if (data) {
290                                         Pman.Dialog.BAdminEmail.dialog.show();
291                                         Pman.Dialog.BAdminEmail.form.findField('bodytext').setValue(data);
292                                     }
293                                 }
294                             );
295                         }
296                       },
297                       xns : Roo.bootstrap,
298                       '|xns' : 'Roo.bootstrap'
299                      },
300                      {
301                       xtype : 'MenuItem',
302                       fa : 'code',
303                       html : _this._strings['73ea6b4441cdced246d236b22c8f991c'] /* HTML File */,
304                       listeners : {
305                        click : function (_self, e)
306                         {
307                             Pman.Dialog.BAdminImage.show(
308                                 {
309                                     _url : '/Core/ImportMailMessage.php'
310                                 },
311                             
312                                 function(data) {
313                                     if (data) {
314                                         Pman.Dialog.BAdminEmail.dialog.show();
315                                         Pman.Dialog.BAdminEmail.form.findField('bodytext').setValue(data);
316                                     }
317                                 }
318                             );
319                         }
320                       },
321                       xns : Roo.bootstrap,
322                       '|xns' : 'Roo.bootstrap'
323                      }
324                     ]
325                    }
326                   }
327                  ]
328                 }
329                ]
330               }
331              ]
332             }
333            ]
334           },
335           {
336            xtype : 'NavItem',
337            xns : Roo.bootstrap,
338            '|xns' : 'Roo.bootstrap',
339            items  : [
340             {
341              xtype : 'Element',
342              xns : Roo.bootstrap,
343              '|xns' : 'Roo.bootstrap',
344              items  : [
345               {
346                xtype : 'Row',
347                cls : 'roo-toolbar',
348                xns : Roo.bootstrap,
349                '|xns' : 'Roo.bootstrap',
350                items  : [
351                 {
352                  xtype : 'Column',
353                  md : 4,
354                  xns : Roo.bootstrap,
355                  '|xns' : 'Roo.bootstrap',
356                  items  : [
357                   {
358                    xtype : 'Input',
359                    placeholder : _this._strings['cffbd822c38679e2fbf11cc182c945e5'] /* search for email template */,
360                    listeners : {
361                     render : function (_self)
362                      {
363                          _this.searchBox = this;
364                      },
365                     specialkey : function (_self, e)
366                      {
367                          _this.table.footer.onClick('first');
368                      }
369                    },
370                    xns : Roo.bootstrap,
371                    '|xns' : 'Roo.bootstrap',
372                    after : {
373                     xtype : 'Button',
374                     html : _this._strings['cdb6b6bab1fd18b9dbfe3fb84a5d34ae'] /* <i class="fa fa-search"></i> */,
375                     listeners : {
376                      click : function (_self, e)
377                       {
378                           _this.table.footer.onClick('first');
379                       }
380                     },
381                     xns : Roo.bootstrap,
382                     '|xns' : 'Roo.bootstrap'
383                    }
384                   }
385                  ]
386                 },
387                 {
388                  xtype : 'Column',
389                  md : 8,
390                  xns : Roo.bootstrap,
391                  '|xns' : 'Roo.bootstrap',
392                  items  : [
393                   {
394                    xtype : 'Button',
395                    html : _this._strings['ed807858fcb68abdd180481f1fcba5c5'] /* <i class="fa fa-trash"></i> Delete */,
396                    style : 'margin-left: 10px; margin-right: 10px; float: right;',
397                    weight : 'primary',
398                    listeners : {
399                     click : function (_self, e)
400                      {
401                          Pman.genericDelete(_this.grid, 'core_email');
402                      },
403                     render : function (_self)
404                      {
405                          _this.delete_btn = this;
406                          
407                          this.hide();
408                      }
409                    },
410                    xns : Roo.bootstrap,
411                    '|xns' : 'Roo.bootstrap'
412                   }
413                  ]
414                 }
415                ]
416               }
417              ]
418             }
419            ]
420           }
421          ]
422         }
423        ]
424       },
425       grid : {
426        xtype : 'Table',
427        hover : true,
428        loadMask : true,
429        responsive : true,
430        rowSelection : true,
431        listeners : {
432         render : function (_self)
433          {
434              
435              _this.table = this;
436              
437              _this.dialog = Pman.Dialog.BAdminEmail;
438          },
439         rowdblclick : function (_self, el, rowIndex, e)
440          {
441              if (!_this.dialog) {
442                  return;
443              }
444              
445              //var data = this.getDataSource().getAt(rowIndex).data;
446              var data = _this.table.store.getAt(rowIndex).data;
447              
448              _this.dialog.show( {id : data.id, module : 'core_email'} , function() {
449                  
450                  _this.table.footer.onClick('first');
451              }); 
452          }
453        },
454        xns : Roo.bootstrap,
455        '|xns' : 'Roo.bootstrap',
456        footer : {
457         xtype : 'PagingToolbar',
458         displayInfo : true,
459         pageSize : 25,
460         xns : Roo.bootstrap,
461         '|xns' : 'Roo.bootstrap'
462        },
463        store : {
464         xtype : 'Store',
465         remoteSort : true,
466         sortInfo : {field:'name',direction:'ASC'},
467         listeners : {
468          beforeload : function (_self, options)
469           {
470               options.params = options.params || {};
471               
472               var s = _this.searchBox.getValue();
473               
474               if(s.length){
475                   options.params['search[nameortitle]'] = s;
476               }
477           
478           },
479          load : function (_self, records, options)
480           {
481               _this.edit_btn.hide();
482               _this.copy_btn.hide();
483               _this.delete_btn.hide();
484           }
485         },
486         xns : Roo.data,
487         '|xns' : 'Roo.data',
488         proxy : {
489          xtype : 'HttpProxy',
490          method : 'GET',
491          url : baseURL+'/Roo/Core_email.php',
492          xns : Roo.data,
493          '|xns' : 'Roo.data'
494         },
495         reader : {
496          xtype : 'JsonReader',
497          fields : [
498              {
499                  "name":"name",
500                  "type":"string"
501              },
502              {
503                  "name":"subject",
504                  "type":"string"
505              }
506          ],
507          id : 'id',
508          root : 'data',
509          totalProperty : 'total',
510          xns : Roo.data,
511          '|xns' : 'Roo.data'
512         }
513        },
514        sm : {
515         xtype : 'RowSelectionModel',
516         singleSelect : true,
517         listeners : {
518          afterselectionchange : function (_self)
519           {
520               _this.edit_btn.hide();
521               _this.copy_btn.hide();
522               _this.delete_btn.hide();
523               
524               if (!this.getSelected()) {
525                   _this.viewPanel.setContent("Nothing Selected");
526                   return;
527               }
528               
529               if(this.getSelected().data) {
530                   _this.viewPanel.setContent(this.getSelected().data.bodytext);
531               }
532               
533               _this.edit_btn.show();
534               _this.copy_btn.show();
535               _this.delete_btn.show();
536               
537           }
538         },
539         xns : Roo.bootstrap.Table,
540         '|xns' : 'Roo.bootstrap.Table'
541        },
542        cm : [
543         {
544          xtype : 'ColumnModel',
545          cursor : 'pointer',
546          dataIndex : 'name',
547          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
548          renderer : function(v,x,r) 
549          { 
550              if(r.data.active * 1 < 1){
551              
552                  return String.format('<span style="font-size:12px;"><s>{0}</s><span>', v ? v : ''); 
553                  
554              }
555              
556              return String.format('<span style="font-size:12px;">{0}<span>', v ? v : ''); 
557          },
558          sortable : true,
559          xs : 3,
560          xns : Roo.grid,
561          '|xns' : 'Roo.grid'
562         },
563         {
564          xtype : 'ColumnModel',
565          cursor : 'pointer',
566          dataIndex : 'subject',
567          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
568          renderer : function(v,x,r) 
569          { 
570              if(r.data.active * 1 < 1){
571                  return String.format('<span style="font-size:12px;"><s>{0}</s></span>', v ? v : ''); 
572              }
573              
574              return String.format('<span style="font-size:12px;">{0}</span>', v ? v : ''); 
575          },
576          sortable : true,
577          xs : 3,
578          xns : Roo.grid,
579          '|xns' : 'Roo.grid'
580         },
581         {
582          xtype : 'ColumnModel',
583          cursor : 'pointer',
584          dataIndex : 'from_email',
585          header : _this._strings['cae905999a2ad1dfb8f4eae0e8cda73b'] /* From Name<br/>Email */,
586          renderer : function(v,x,r)
587          {
588              var from_name = r.data.from_name ? r.data.from_name : '';
589              var from_email = r.data.from_email ? r.data.from_email : '';
590              
591              //var r = from_name + '<br>' + from_email ;
592              if(from_name =='') {
593                  return String.format('<span style="font-size:12px;">{0}</span>', from_email);
594              }
595              return String.format('<span style="font-size:12px;">{0} <br> {1}</span>', from_name, from_email);
596              
597              /*
598              return String.format(
599                  '{0}'+'<'+'{1}'+'>',
600                  r.data.from_name ? r.data.from_name : '',
601                  r.data.from_email ? r.data.from_email : ''
602              );
603              */
604          },
605          xs : 3,
606          xns : Roo.grid,
607          '|xns' : 'Roo.grid'
608         },
609         {
610          xtype : 'ColumnModel',
611          cursor : 'pointer',
612          dataIndex : 'to_group_name',
613          header : _this._strings['98d2ee61ddce0c7666297d81639914f1'] /* To / BCC Group */,
614          renderer : function(v,x,r)
615          { 
616              if(r.data.group_member_count * 1 < 1 && r.data.to_group_name !=''){
617                  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 ); 
618              }
619              if(r.data.to_group_name ==''){
620                  return String.format('<span style="font-size:12px;">BCC: {0}</span>', r.data.bcc_group_name ); 
621              }
622          
623              return String.format('<span style="font-size:12px;">To: {0} <br>BCC: {1}</span>', r.data.to_group_name,r.data.bcc_group_name ); 
624          },
625          xs : 3,
626          xns : Roo.grid,
627          '|xns' : 'Roo.grid'
628         },
629         {
630          xtype : 'ColumnModel',
631          cursor : 'pointer',
632          dataIndex : 'bcc_group_name',
633          header : _this._strings['68b00d723d37122f64da8d9939f836f0'] /* BCC Group */,
634          hidden : true,
635          renderer : function(v) { return String.format('{0}', v ? v : ''); },
636          xs : 2,
637          xns : Roo.grid,
638          '|xns' : 'Roo.grid'
639         }
640        ]
641       }
642      },
643      {
644       xtype : 'Content',
645       fitToFrame : true,
646       region : 'south',
647       title : _this._strings['9e11143e29a031212f2cdefcf61f39e9'] /* View Message */,
648       listeners : {
649        render : function (_self)
650         {
651             _this.viewPanel = this;
652         }
653       },
654       xns : Roo.bootstrap.panel,
655       '|xns' : 'Roo.bootstrap.panel'
656      }
657     ]
658    }
659   };  }
660 });