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