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