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   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
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            xns : Roo.bootstrap,
107            '|xns' : 'Roo.bootstrap',
108            items  : [
109             {
110              xtype : 'Element',
111              xns : Roo.bootstrap,
112              '|xns' : 'Roo.bootstrap',
113              items  : [
114               {
115                xtype : 'Row',
116                cls : 'roo-toolbar',
117                xns : Roo.bootstrap,
118                '|xns' : 'Roo.bootstrap',
119                items  : [
120                 {
121                  xtype : 'Column',
122                  md : 4,
123                  xns : Roo.bootstrap,
124                  '|xns' : 'Roo.bootstrap',
125                  items  : [
126                   {
127                    xtype : 'Input',
128                    placeholder : _this._strings['cffbd822c38679e2fbf11cc182c945e5'] /* search for email template */,
129                    listeners : {
130                     render : function (_self)
131                      {
132                          _this.searchBox = this;
133                      },
134                     specialkey : function (_self, e)
135                      {    
136                           if(e.keyCode == e.ENTER) {
137                              if (_this.table) {
138                                  _this.table.footer.onClick('first'); 
139                              }
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         rowclick : function (_self, el, rowIndex, e)
359          {
360              
361          },
362         rowdblclick : function (_self, el, rowIndex, e)
363          {
364              if (!_this.dialog) {
365                  return;
366              }
367              
368              //var data = this.getDataSource().getAt(rowIndex).data;
369              var data = _this.table.store.getAt(rowIndex).data;
370              
371              _this.dialog.show( {id : data.id, module : 'core_email'} , function() {
372                  
373                  _this.table.footer.onClick('first');
374              }); 
375          }
376        },
377        xns : Roo.bootstrap,
378        '|xns' : 'Roo.bootstrap',
379        footer : {
380         xtype : 'PagingToolbar',
381         displayInfo : true,
382         pageSize : 25,
383         xns : Roo.bootstrap,
384         '|xns' : 'Roo.bootstrap'
385        },
386        store : {
387         xtype : 'Store',
388         remoteSort : true,
389         sortInfo : {field:'name',direction:'ASC'},
390         listeners : {
391          beforeload : function (_self, options)
392           {
393               if (!Pman.buildCompleted) {
394                   return false;
395               }
396               
397               options.params = options.params || {};
398               
399               var s = _this.searchBox.getValue();
400               
401               if(s.length){
402                   options.params['search[nameortitle]'] = s;
403               }
404           
405           },
406          load : function (_self, records, options)
407           {
408               _this.edit_btn.hide();
409               _this.copy_btn.hide();
410               _this.delete_btn.hide();
411           }
412         },
413         xns : Roo.data,
414         '|xns' : 'Roo.data',
415         proxy : {
416          xtype : 'HttpProxy',
417          method : 'GET',
418          url : baseURL+'/Roo/Core_email.php',
419          xns : Roo.data,
420          '|xns' : 'Roo.data'
421         },
422         reader : {
423          xtype : 'JsonReader',
424          fields : [
425              {
426                  "name":"name",
427                  "type":"string"
428              },
429              {
430                  "name":"subject",
431                  "type":"string"
432              }
433          ],
434          id : 'id',
435          root : 'data',
436          totalProperty : 'total',
437          xns : Roo.data,
438          '|xns' : 'Roo.data'
439         }
440        },
441        sm : {
442         xtype : 'RowSelectionModel',
443         singleSelect : true,
444         listeners : {
445          afterselectionchange : function (_self)
446           {
447               _this.edit_btn.hide();
448               _this.copy_btn.hide();
449               _this.delete_btn.hide();
450               
451               if (!this.getSelected()) {
452                   _this.viewPanel.setContent("Nothing Selected");
453                   return;
454               }
455               
456               if(this.getSelected().data) {
457                   _this.viewPanel.setContent(this.getSelected().data.bodytext);
458               }
459               
460               _this.edit_btn.show();
461               _this.copy_btn.show();
462               _this.delete_btn.show();
463               
464           }
465         },
466         xns : Roo.bootstrap.Table,
467         '|xns' : 'Roo.bootstrap.Table'
468        },
469        cm : [
470         {
471          xtype : 'ColumnModel',
472          align : 'center',
473          cursor : 'pointer',
474          dataIndex : 'active',
475          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
476          renderer : function(v) {  
477          
478              var state = v > 0 ?  'check-' : '';
479              var cls = v > 0 ? 'text-primary' : '';
480              
481              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
482                          
483           },
484          sortable : true,
485          xs : 1,
486          xns : Roo.grid,
487          '|xns' : 'Roo.grid'
488         },
489         {
490          xtype : 'ColumnModel',
491          cursor : 'pointer',
492          dataIndex : 'description',
493          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
494          renderer : function(v,x,r) 
495          { 
496              if(r.data.active * 1 < 1){
497                  return String.format('<small">{0}</small>', v ? v : ''); 
498              }
499              
500              return String.format('<b>{0}</b>', v ? v : ''); 
501          },
502          sortable : true,
503          xs : 3,
504          xns : Roo.grid,
505          '|xns' : 'Roo.grid'
506         },
507         {
508          xtype : 'ColumnModel',
509          cursor : 'pointer',
510          dataIndex : 'subject',
511          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
512          renderer : function(v,x,r) 
513          { 
514              if(r.data.active * 1 < 1){
515                  return String.format('<small">{0}</small>', v ? v : ''); 
516              }
517              
518              return String.format('<b>{0}</b>', v ? v : ''); 
519          },
520          sortable : true,
521          xs : 3,
522          xns : Roo.grid,
523          '|xns' : 'Roo.grid'
524         },
525         {
526          xtype : 'ColumnModel',
527          cursor : 'pointer',
528          dataIndex : 'from_email',
529          header : _this._strings['cae905999a2ad1dfb8f4eae0e8cda73b'] /* From Name<br/>Email */,
530          renderer : function(v,x,r)
531          {
532              if(r.data.active * 1 < 1){
533                  return '';
534              }
535              
536              var from_name = r.data.from_name ? r.data.from_name : '';
537              var from_email = r.data.from_email ? r.data.from_email : '';
538              
539              if(from_name =='') {
540                  return String.format('<small>{0}</small>', from_email);
541              }
542              
543              return String.format('<small>{0} <br> {1}</small>', from_name, from_email);
544              
545          },
546          xs : 2,
547          xns : Roo.grid,
548          '|xns' : 'Roo.grid'
549         },
550         {
551          xtype : 'ColumnModel',
552          cursor : 'pointer',
553          dataIndex : 'to_group_name',
554          header : _this._strings['98d2ee61ddce0c7666297d81639914f1'] /* To / BCC Group */,
555          renderer : function(v,x,r)
556          { 
557              if(r.data.active * 1 < 1){
558                  return '';
559              }
560              
561              var nid = r.data.to_group_id * 1 ;
562              var n = nid > 0 ? r.data.group_member_count * 1 : 0;
563              var grp_str = String.format('<small>To: {0} ' + 
564                      '<span class="badge' + (n > 0 ?  '' : ' badge-danger') + '">{1}</span></small><br>',
565                      r.data.to_group_id_name,
566                      nid < 1 ? 'Not set' : n
567                  );
568             
569              if (nid < 0) { // no To needed..
570                  grp_str = '';
571              }
572              nid = r.data.bcc_group_id * 1;
573              n = nid > 0 ? r.data.bcc_group_member_count * 1 : 0;
574          
575              var bcc_str = String.format('<small>BCC: {0} <span class="badge' + (n > 0 ?  '' : ' badge-danger') + '">{1}</span></small>',
576                      r.data.bcc_group_id_name,
577                      nid < 1 ? 'Not set' : n
578                  );
579                  
580              if (nid < 0) { // no To needed..
581                  bcc_str = '';
582              }  
583              
584              return grp_str + bcc_str;
585          },
586          xs : 3,
587          xns : Roo.grid,
588          '|xns' : 'Roo.grid'
589         }
590        ]
591       }
592      },
593      {
594       xtype : 'Content',
595       fitToFrame : true,
596       region : 'south',
597       title : _this._strings['9e11143e29a031212f2cdefcf61f39e9'] /* View Message */,
598       listeners : {
599        render : function (_self)
600         {
601             _this.viewPanel = this;
602         }
603       },
604       xns : Roo.bootstrap.panel,
605       '|xns' : 'Roo.bootstrap.panel'
606      }
607     ]
608    }
609   };  }
610 });