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