PHP8
[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        rowSelection : true,
372        listeners : {
373         cellclick : function (_self, el, rowIndex, columnIndex, e)
374          {
375              var di = this.colModel.getDataIndex(columnIndex);
376              
377               if(di != 'active'){
378                   return;
379               }
380               
381               var r = this.store.getAt(rowIndex);
382               
383              if(r.data.active * 1  < 1){
384              
385                  Pman.Dialog.BAdminEmail.show( {id : r.data.id, module : 'core_email'} , function() {
386                      _this.table.footer.onClick('refresh');
387                  });
388                  
389                  return;
390              }
391              
392              r.set('active', 0);
393              r.commit();
394              
395               
396          },
397         render : function (_self)
398          {
399              
400              _this.table = this;
401              
402              _this.dialog = Pman.Dialog.BAdminEmail;
403          },
404         rowdblclick : function (_self, el, rowIndex, e)
405          {
406              if (!_this.dialog) {
407                  return;
408              }
409              
410              //var data = this.getDataSource().getAt(rowIndex).data;
411              var data = _this.table.store.getAt(rowIndex).data;
412              
413              _this.dialog.show( {id : data.id, module : 'core_email'} , function() {
414                  
415                  _this.table.footer.onClick('refresh');
416              }); 
417          }
418        },
419        xns : Roo.bootstrap,
420        '|xns' : 'Roo.bootstrap',
421        footer : {
422         xtype : 'PagingToolbar',
423         displayInfo : true,
424         pageSize : 25,
425         xns : Roo.bootstrap,
426         '|xns' : 'Roo.bootstrap'
427        },
428        store : {
429         xtype : 'Store',
430         remoteSort : true,
431         sortInfo : {field:'description',direction:'ASC'},
432         listeners : {
433          beforeload : function (_self, options)
434           {
435               if (!Pman.buildCompleted) {
436                   return false;
437               }
438               
439               options.params = options.params || {};
440               
441               var s = _this.searchBox.getValue();
442               
443               if(s.length){
444                   options.params['search[nameortitle]'] = s;
445               }
446               // hide our system emails.
447               if (appDisabled.indexOf('Core.SuperAdmin') > -1) {
448                   options.params._hide_system_emails = 1;
449               } 
450           
451           },
452          load : function (_self, records, options)
453           {
454               _this.edit_btn.hide();
455               _this.copy_btn.hide();
456               _this.delete_btn.hide();
457           },
458          update : function (_self, record, operation)
459           {
460               if (operation != 'commit') {
461                   return;
462               }
463           
464               new Pman.Request({
465                   url : baseURL + '/Roo/Core_email',
466                   method : 'POST',
467                   params : {
468                     id : record.data.id,
469                     active : record.data.active
470                   },
471                   success : function() { 
472                       _this.table.footer.onClick('refresh');
473                   }
474             });
475           }
476         },
477         xns : Roo.data,
478         '|xns' : 'Roo.data',
479         proxy : {
480          xtype : 'HttpProxy',
481          method : 'GET',
482          url : baseURL+'/Roo/Core_email.php',
483          xns : Roo.data,
484          '|xns' : 'Roo.data'
485         },
486         reader : {
487          xtype : 'JsonReader',
488          fields : [
489              {
490                  "name":"name",
491                  "type":"string"
492              },
493              {
494                  "name":"subject",
495                  "type":"string"
496              },
497              {
498                  "name":"description",
499                  "type":"string"
500              }
501          ],
502          id : 'id',
503          root : 'data',
504          totalProperty : 'total',
505          xns : Roo.data,
506          '|xns' : 'Roo.data'
507         }
508        },
509        sm : {
510         xtype : 'RowSelectionModel',
511         singleSelect : true,
512         listeners : {
513          afterselectionchange : function (_self)
514           {
515               _this.edit_btn.hide();
516               _this.copy_btn.hide();
517               _this.delete_btn.hide();
518               
519               if (!this.getSelected()) {
520                   _this.viewPanel.setContent("Nothing Selected");
521                   return;
522               }
523               
524               if(this.getSelected().data) {
525                   _this.viewPanel.setContent(this.getSelected().data.bodytext);
526               }
527               
528               _this.edit_btn.show();
529               _this.copy_btn.show();
530               _this.delete_btn.show();
531               
532           }
533         },
534         xns : Roo.bootstrap.Table,
535         '|xns' : 'Roo.bootstrap.Table'
536        },
537        cm : [
538         {
539          xtype : 'ColumnModel',
540          align : 'center',
541          cursor : 'pointer',
542          dataIndex : 'active',
543          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
544          renderer : function(v) {  
545          
546              var state = v > 0 ?  'check-' : '';
547              var cls = v > 0 ? 'text-primary' : '';
548              
549              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
550                          
551           },
552          sortable : true,
553          xs : 1,
554          xns : Roo.grid,
555          '|xns' : 'Roo.grid'
556         },
557         {
558          xtype : 'ColumnModel',
559          cursor : 'pointer',
560          dataIndex : 'description',
561          header : _this._strings['b5a7adde1af5c87d7fd797b6245c2a39'] /* Description */,
562          renderer : function(v,x,r) 
563          { 
564              vv = (v.length) ? v : r.data.name;
565              
566              if(r.data.active * 1 < 1){
567                  return '<small style="color: #999;">' + vv + '</small>';
568              }
569              
570              return '<b>' + vv + '</b>';
571          },
572          sortable : true,
573          xs : 4,
574          xns : Roo.grid,
575          '|xns' : 'Roo.grid'
576         },
577         {
578          xtype : 'ColumnModel',
579          cursor : 'pointer',
580          dataIndex : 'from_email',
581          header : _this._strings['cae905999a2ad1dfb8f4eae0e8cda73b'] /* From Name<br/>Email */,
582          renderer : function(v,x,r)
583          {
584              if(r.data.active * 1 < 1){
585                  return '';
586              }
587              
588              return String.format('<small>{0}</small>', r.data.from_name );
589              
590          },
591          xs : 3,
592          xns : Roo.grid,
593          '|xns' : 'Roo.grid'
594         },
595         {
596          xtype : 'ColumnModel',
597          cursor : 'pointer',
598          dataIndex : 'to_group_name',
599          header : _this._strings['98d2ee61ddce0c7666297d81639914f1'] /* To / BCC Group */,
600          renderer : function(v,x,r)
601          { 
602              if(r.data.active * 1 < 1){
603                  return '';
604              }
605              
606              var nid = r.data.to_group_id * 1 ;
607              var n = nid > 0 ? r.data.group_member_count * 1 : 0;
608              var grp_str = String.format('<small>To: {0} ' + 
609                      '<span class="badge' + (n > 0 ?  '' : ' badge-danger') + '">{1}</span></small><br>',
610                      r.data.to_group_id_name,
611                      nid < 1 ? 'Not set' : n
612                  );
613             
614              if (nid < 0) { // no To needed..
615                  grp_str = '';
616              }
617              nid = r.data.bcc_group_id * 1;
618              n = nid > 0 ? r.data.bcc_group_member_count * 1 : 0;
619          
620              var bcc_str = String.format('<small>BCC: {0} <span class="badge' + (n > 0 ?  '' : ' badge-danger') + '">{1}</span></small>',
621                      r.data.bcc_group_id_name,
622                      nid < 1 ? 'Not set' : n
623                  );
624                  
625              if (nid < 0) { // no To needed..
626                  bcc_str = '';
627              }  
628              
629              return grp_str + bcc_str;
630          },
631          xs : 4,
632          xns : Roo.grid,
633          '|xns' : 'Roo.grid'
634         }
635        ]
636       }
637      },
638      {
639       xtype : 'Content',
640       fitToFrame : true,
641       region : 'south',
642       title : _this._strings['9e11143e29a031212f2cdefcf61f39e9'] /* View Message */,
643       listeners : {
644        render : function (_self)
645         {
646             _this.viewPanel = this;
647         }
648       },
649       xns : Roo.bootstrap.panel,
650       '|xns' : 'Roo.bootstrap.panel'
651      }
652     ]
653    }
654   };  }
655 });