Pman.Dialog.CoreNotifyRecur.bjs
[Pman.Core] / Pman.Dialog.CoreNotifyRecur.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.Dialog');
6
7 Pman.Dialog.CoreNotifyRecur = {
8
9  _strings : {
10   '3728af837fe70019577ddb0ed7125ee5' :"Until",
11   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
12   '023a5dfa857c4aa0156e6685231a1dbd' :"Select Type",
13   '6c768695a8efb18436d5b7b4374cdb45' :"Select core_enum",
14   '157e432ec303efd7d537b653cb255ccc' :"on day(s)",
15   '236df51bb0e6416236e255b528346fca' :"Timezone",
16   '44c68bed631ff6e62aecc4a4d32176e6' :"Select timezone",
17   '867343577fa1f33caa632a19543bd252' :"Keywords",
18   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
19   'b26686c0a708faee42861d8b905e882e' :"Last Sent",
20   'c1d32776cd2d2afcd2c45a52f58679f4' :"Modify Recurrent Notifications",
21   '5da618e8e4b89c66fe86e32cdafde142' :"From",
22   'ce527d7432bab413730f25c794648e46' :"at Hour(s)",
23   'c7179f16884513c990b6cbf44aef7fc3' :"core_notify_recur",
24   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
25   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
26   'f92965e2c8a7afb3c1b9a5c09a263636' :"Done"
27  },
28
29  dialog : false,
30  callback:  false,
31
32  show : function(data, cb)
33  {
34   if (!this.dialog) {
35    this.create();
36   }
37
38   this.callback = cb;
39   this.data = data;
40   this.dialog.show(this.data._el);
41   if (this.form) {
42    this.form.reset();
43    this.form.setValues(data);
44    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
45   }
46
47  },
48
49  create : function()
50  {
51    var _this = this;
52    this.dialog = Roo.factory({
53     center : {
54      '|xns' : 'Roo',
55      autoScroll : true,
56      loadOnce : true,
57      xns : Roo,
58      xtype : 'LayoutRegion'
59     },
60     '|xns' : 'Roo',
61     height : 550,
62     modal : true,
63     resizable : false,
64     title : _this._strings['c1d32776cd2d2afcd2c45a52f58679f4'],
65     width : 800,
66     xns : Roo,
67     xtype : 'LayoutDialog',
68     buttons : [
69       {
70        '|xns' : 'Roo',
71        text : _this._strings['f92965e2c8a7afb3c1b9a5c09a263636'],
72        xns : Roo,
73        xtype : 'Button',
74        listeners : {
75         click : function (_self, e)
76          {
77              _this.dialog.hide();
78          }
79        }
80       }
81     ],
82     listeners : {
83      show : function (_self)
84       {
85           _this.grid.ds.load({});
86       }
87     },
88     items : [
89      {
90       grid : {
91        dataSource : {
92         proxy : {
93          '|xns' : 'Roo.data',
94          method : 'GET',
95          url : baseURL + '/Roo/core_notify_recur.php',
96          xns : Roo.data,
97          xtype : 'HttpProxy'
98         },
99         reader : {
100          '|xns' : 'Roo.data',
101          fields : [
102              {
103                  'name': 'id',
104                  'type': 'int'
105              },
106              {
107                  'name': 'person_id',
108                  'type': 'int'
109              },
110              {
111                  'name': 'dtstart',
112                  'type': 'date',
113                  'dateFormat': 'Y-m-d'
114              },
115              {
116                  'name': 'dtend',
117                  'type': 'date',
118                  'dateFormat': 'Y-m-d'
119              },
120              {
121                  'name': 'tz',
122                  'type': 'float'
123              },
124              {
125                  'name': 'last_applied_dt',
126                  'type': 'date',
127                  'dateFormat': 'Y-m-d'
128              },
129              {
130                  'name': 'freq',
131                  'type': 'string'
132              },
133              {
134                  'name': 'freq_day',
135                  'type': 'string'
136              },
137              {
138                  'name': 'freq_hour',
139                  'type': 'string'
140              },
141              {
142                  'name': 'last_event_id',
143                  'type': 'int'
144              },
145              {
146                  'name': 'method',
147                  'type': 'string'
148              }
149          ],
150          id : 'id',
151          root : 'data',
152          totalProperty : 'total',
153          xns : Roo.data,
154          xtype : 'JsonReader'
155         },
156         '|xns' : 'Roo.data',
157         remoteSort : true,
158         sortInfo : { field : 'freq', direction: 'ASC' },
159         xns : Roo.data,
160         xtype : 'Store',
161         listeners : {
162          beforeload : function (_self, o)
163           {
164               if (!_this.data) {
165                   return false;
166               }
167               o.params =  Roo.apply(o.params || {}, {
168                   person_id : _this.data.person_id,
169                   onid : _this.data.onid,
170                   ontable : _this.data.ontable,
171                   method : _this.data.method
172               });
173                   
174           },
175          update : function (_self, record, operation)
176           {
177               //Roo.log(operation);
178               if (operation != 'commit') {
179                   return;
180               }
181               var p = Roo.apply({}, record.data);
182               p.dtstart = record.data.dtstart.format('Y-m-d');
183               p.dtend = record.data.dtend.format('Y-m-d');    
184               
185               
186               new Pman.Request({
187                   url : baseURL + '/Roo/Core_notify_recur',
188                   method :'POST',
189                   params : p,
190                   success : function(data)
191                   {
192                       //Roo.log(data);
193                       record.set('id', data.data.id);
194                   },
195                   failure : function() {
196                       Roo.MessageBox.alert("Error", "There was a problem saving");
197                   }
198               });
199                  
200               
201               
202           }
203         },
204         items : [
205
206         ]
207
208        },
209        toolbar : {
210         '|xns' : 'Roo',
211         xns : Roo,
212         xtype : 'Toolbar',
213         items : [
214          {
215           '|xns' : 'Roo.Toolbar',
216           cls : 'x-btn-text-icon',
217           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
218           text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'],
219           xns : Roo.Toolbar,
220           xtype : 'Button',
221           listeners : {
222            click : function()
223             {
224                 var grid = _this.grid;
225                 var r = grid.getDataSource().reader.newRow({
226                 // defaults..
227                     person_id : _this.data.person_id,
228                     dtstart : new Date(),
229                     dtend : Date.parseDate('2050-01-01', 'Y-m-d'),
230                     tz : 'Asia/Hong_Kong',
231                     onid : _this.data.onid,
232                     ontable : _this.data.ontable,
233                     method : _this.data.method, // default...
234                     
235                     method_id : _this.data.method_id, // default...
236                     method_id_display_name : _this.data.method_id_display_name, // default...        
237                     
238                     last_event_id : 0,
239                     freq_day_name : '',
240                     freq_hour_name : '',
241                     freq_name : ''
242                     
243                 
244                 });
245                 grid.stopEditing();
246                 grid.getDataSource().insert(0, r); 
247                 grid.startEditing(0, 2); 
248                 
249             
250             }
251           }
252          },
253          {
254           '|xns' : 'Roo.Toolbar',
255           xns : Roo.Toolbar,
256           xtype : 'Fill'
257          },
258          {
259           '|xns' : 'Roo.Toolbar',
260           cls : 'x-btn-text-icon',
261           icon : rootURL + '/Pman/templates/images/trash.gif',
262           text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'],
263           xns : Roo.Toolbar,
264           xtype : 'Button',
265           listeners : {
266            click : function()
267             {
268                  _this.grid.stopEditing();
269                  var s = _this.grid.selModel.getSelectedCell();
270                  if (!s) {
271                     Roo.MessageBox.alert("Error", "Select row");
272                     return;
273                 }
274                 
275                 new Pman.Request({
276                     url : baseURL + '/Roo/core_notify_recur',
277                     method : 'POST',
278                     params : {
279                         _delete : _this.grid.ds.getAt(s[0]).data.id
280                     }, 
281                     success : function() {
282                         _this.grid.ds.load({});
283                     },
284                     failure : function() {
285                         Roo.MessageBox.alert("Error", "Deleting failed - try reloading");
286                     }
287                });
288                 
289             }
290           }
291          }
292         ]
293
294        },
295        '|xns' : 'Roo.grid',
296        autoExpandColumn : 'freq_day',
297        clicksToEdit : 1,
298        loadMask : true,
299        xns : Roo.grid,
300        xtype : 'EditorGrid',
301        colModel : [
302          {
303           editor : {
304            field : {
305             store : {
306              proxy : {
307               '|xns' : 'Roo.data',
308               method : 'GET',
309               url : baseURL + '/Roo/core_enum.php',
310               xns : Roo.data,
311               xtype : 'HttpProxy'
312              },
313              reader : {
314               '|xns' : 'Roo.data',
315               fields : [{"name":"id","type":"int"},{"name":"etype","type":"string"}],
316               id : 'id',
317               root : 'data',
318               totalProperty : 'total',
319               xns : Roo.data,
320               xtype : 'JsonReader'
321              },
322              '|xns' : 'Roo.data',
323              remoteSort : true,
324              sortInfo : { direction : 'ASC', field: 'id' },
325              xns : Roo.data,
326              xtype : 'Store',
327              listeners : {
328               beforeload : function (_self, o){
329                    o.params = o.params || {};
330                    // set more here
331                    o.params.etype = 'core_notify_recur';
332                }
333              },
334              items : [
335
336              ]
337
338             },
339             '|xns' : 'Roo.form',
340             allowBlank : false,
341             displayField : 'display_name',
342             editable : false,
343             emptyText : _this._strings['023a5dfa857c4aa0156e6685231a1dbd'],
344             fieldLabel : 'core_enum',
345             forceSelection : true,
346             hiddenName : 'method_id',
347             listWidth : 400,
348             loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'],
349             name : 'method_id_display_name',
350             pageSize : 20,
351             qtip : _this._strings['6c768695a8efb18436d5b7b4374cdb45'],
352             selectOnFocus : true,
353             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
354             triggerAction : 'all',
355             typeAhead : true,
356             valueField : 'id',
357             width : 300,
358             xns : Roo.form,
359             xtype : 'ComboBox',
360             items : [
361
362             ]
363
364            },
365            '|xns' : 'Roo.grid',
366            xns : Roo.grid,
367            xtype : 'GridEditor',
368            items : [
369
370            ]
371
372           },
373           '|xns' : 'Roo.grid',
374           dataIndex : 'method_id',
375           header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'],
376           renderer : function(v,x,r) {
377                return String.format('{0}', r.data.method_id_display_name); 
378           },
379           width : 120,
380           xns : Roo.grid,
381           xtype : 'ColumnModel',
382           items : [
383
384           ]
385
386          },
387 {
388           editor : {
389            field : {
390             '|xns' : 'Roo.form',
391             xns : Roo.form,
392             xtype : 'DateField'
393            },
394            '|xns' : 'Roo.grid',
395            xns : Roo.grid,
396            xtype : 'GridEditor',
397            items : [
398
399            ]
400
401           },
402           '|xns' : 'Roo.grid',
403           dataIndex : 'dtstart',
404           header : _this._strings['5da618e8e4b89c66fe86e32cdafde142'],
405           renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
406           width : 75,
407           xns : Roo.grid,
408           xtype : 'ColumnModel',
409           items : [
410
411           ]
412
413          },
414 {
415           editor : {
416            field : {
417             '|xns' : 'Roo.form',
418             xns : Roo.form,
419             xtype : 'DateField'
420            },
421            '|xns' : 'Roo.grid',
422            xns : Roo.grid,
423            xtype : 'GridEditor',
424            items : [
425
426            ]
427
428           },
429           '|xns' : 'Roo.grid',
430           dataIndex : 'dtend',
431           header : _this._strings['3728af837fe70019577ddb0ed7125ee5'],
432           renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
433           width : 75,
434           xns : Roo.grid,
435           xtype : 'ColumnModel',
436           items : [
437
438           ]
439
440          },
441 {
442           editor : {
443            field : {
444             store : {
445              '|xns' : 'Roo.data',
446              data : (function() { 
447                  var ret = [];
448                  Roo.each(Date.dayNames, function(d) {
449                      ret.push([ d.substring(0,3).toUpperCase(), d ]);
450                  });
451                  return ret;
452              })(),
453              fields : ['code', 'title'],
454              sortInfo : { field : 'title', direction: 'ASC' },
455              xns : Roo.data,
456              xtype : 'SimpleStore'
457             },
458             '|xns' : 'Roo.form',
459             allowBlank : false,
460             displayField : 'title',
461             editable : false,
462             fieldLabel : 'Country',
463             hiddenName : 'freq_day',
464             listWidth : 300,
465             mode : 'local',
466             name : 'freq_day_name',
467             pageSize : 40,
468             triggerAction : 'all',
469             valueField : 'code',
470             xns : Roo.form,
471             xtype : 'ComboCheck',
472             items : [
473
474             ]
475
476            },
477            '|xns' : 'Roo.grid',
478            xns : Roo.grid,
479            xtype : 'GridEditor',
480            items : [
481
482            ]
483
484           },
485           '|xns' : 'Roo.grid',
486           dataIndex : 'freq_day',
487           header : _this._strings['157e432ec303efd7d537b653cb255ccc'],
488           renderer : function(v,x,r) { 
489               
490               if (v.length) {
491                
492                   var cm = _this.grid.colModel;
493                  
494                   var ci = cm.getColumnByDataIndex(this.name);
495                  
496                    var tv = [];
497                   var vals = Roo.decode(v);
498                   Roo.each(vals, function(k) {
499                       var r = this.findRecord(this.valueField, k);
500                       if(r){
501                           tv.push(r.data[this.displayField]);
502                       }else if(this.valueNotFoundText !== undefined){
503                           tv.push( this.valueNotFoundText );
504                       }
505                   },ci.editor.field);
506           
507                   r.data[this.name + '_name'] = tv.join(', ');
508                   return String.format('{0}',tv.join(', '));
509           
510                   
511               
512               }
513               r.data[this.name + '_name'] = '';
514               return String.format('{0}', r.data.freq_day_name || v); 
515               
516           },
517           width : 100,
518           xns : Roo.grid,
519           xtype : 'ColumnModel',
520           items : [
521
522           ]
523
524          },
525 {
526           editor : {
527            field : {
528             store : {
529              '|xns' : 'Roo.data',
530              data : (function() { 
531                  var ret = [];
532                  for (var i = 5; i < 25; i++) {
533                      var h = i < 10 ? ('0' + i) : i;
534                      var mer = i < 12 || i > 23 ? 'am' : 'pm';
535                      var dh = i < 13 ? i : i-12;
536                      
537                      ret.push([ h+':00', dh+':00' + mer ]);
538                      ret.push([ h+':30', dh+':30' + mer ]);        
539                  }
540                  return ret;
541              })(),
542              fields : ['code', 'title'],
543              sortInfo : { field : 'title', direction: 'ASC' },
544              xns : Roo.data,
545              xtype : 'SimpleStore'
546             },
547             '|xns' : 'Roo.form',
548             allowBlank : false,
549             displayField : 'title',
550             editable : false,
551             fieldLabel : 'Country',
552             hiddenName : 'freq_hour',
553             listWidth : 300,
554             mode : 'local',
555             name : 'freq_hour_name',
556             pageSize : 40,
557             triggerAction : 'all',
558             valueField : 'code',
559             xns : Roo.form,
560             xtype : 'ComboCheck',
561             items : [
562
563             ]
564
565            },
566            '|xns' : 'Roo.grid',
567            xns : Roo.grid,
568            xtype : 'GridEditor',
569            items : [
570
571            ]
572
573           },
574           '|xns' : 'Roo.grid',
575           dataIndex : 'freq_hour',
576           header : _this._strings['ce527d7432bab413730f25c794648e46'],
577           renderer : function(v,x,r) { 
578               
579            
580               if (v.length) {
581                
582                   var cm = _this.grid.colModel;
583                  
584                   var ci = cm.getColumnByDataIndex(this.name);
585                  
586                    var tv = [];
587                   var vals = Roo.decode(v);
588                   Roo.each(vals, function(k) {
589                       var r = this.findRecord(this.valueField, k);
590                       if(r){
591                           tv.push(r.data[this.displayField]);
592                       }else if(this.valueNotFoundText !== undefined){
593                           tv.push( this.valueNotFoundText );
594                       }
595                   },ci.editor.field);
596           
597                    r.data[this.name + '_name'] = tv.join(', ');
598                   return String.format('{0}',tv.join(', '));
599           
600                   
601               
602               }
603                   r.data[this.name + '_name'] = '';
604               return String.format('{0}', r.data.freq_hour_name || v); 
605               
606           },
607           width : 100,
608           xns : Roo.grid,
609           xtype : 'ColumnModel',
610           items : [
611
612           ]
613
614          },
615 {
616           editor : {
617            field : {
618             store : {
619              proxy : {
620               '|xns' : 'Roo.data',
621               method : 'GET',
622               url : baseURL + '/Core/I18n/Timezone.php',
623               xns : Roo.data,
624               xtype : 'HttpProxy'
625              },
626              reader : {
627               '|xns' : 'Roo.data',
628               fields : [{"name":"tz","type":"string"}],
629               id : 'id',
630               root : 'data',
631               totalProperty : 'total',
632               xns : Roo.data,
633               xtype : 'JsonReader'
634              },
635              '|xns' : 'Roo.data',
636              remoteSort : true,
637              sortInfo : { direction : 'ASC', field: 'tz' },
638              xns : Roo.data,
639              xtype : 'Store',
640              listeners : {
641               beforeload : function (_self, o){
642                    o.params = o.params || {};
643                    // set more here
644                }
645              },
646              items : [
647
648              ]
649
650             },
651             '|xns' : 'Roo.form',
652             allowBlank : false,
653             displayField : 'tz',
654             editable : true,
655             emptyText : _this._strings['44c68bed631ff6e62aecc4a4d32176e6'],
656             fieldLabel : 'core_enum',
657             forceSelection : true,
658             listWidth : 400,
659             loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'],
660             minChars : 2,
661             name : 'tz',
662             pageSize : 999,
663             qtip : _this._strings['44c68bed631ff6e62aecc4a4d32176e6'],
664             queryParam : 'q',
665             selectOnFocus : true,
666             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{tz}</b> </div>',
667             triggerAction : 'all',
668             typeAhead : true,
669             width : 300,
670             xns : Roo.form,
671             xtype : 'ComboBox',
672             items : [
673
674             ]
675
676            },
677            '|xns' : 'Roo.grid',
678            xns : Roo.grid,
679            xtype : 'GridEditor',
680            items : [
681
682            ]
683
684           },
685           '|xns' : 'Roo.grid',
686           dataIndex : 'tz',
687           header : _this._strings['236df51bb0e6416236e255b528346fca'],
688           renderer : function(v) { return String.format('{0}', v); },
689           width : 100,
690           xns : Roo.grid,
691           xtype : 'ColumnModel',
692           items : [
693
694           ]
695
696          },
697 {
698           '|xns' : 'Roo.grid',
699           dataIndex : 'last_event_id',
700           header : _this._strings['b26686c0a708faee42861d8b905e882e'],
701           renderer : function(v) { return String.format('{0}', v ? v : 'never'); },
702           width : 75,
703           xns : Roo.grid,
704           xtype : 'ColumnModel'
705          },
706 {
707           '|xns' : 'Roo.grid',
708           dataIndex : 'last_event_id',
709           header : _this._strings['867343577fa1f33caa632a19543bd252'],
710           renderer : function(v) { return String.format('{0}', v ? v : ''); },
711           width : 75,
712           xns : Roo.grid,
713           xtype : 'ColumnModel'
714          }
715        ],
716        listeners : {
717         afteredit : function (e)
718          {
719             e.record.commit();
720          },
721         render : function() 
722          {
723              _this.grid = this; 
724              //_this.dialog = Pman.Dialog.FILL_IN
725              if (_this.panel.active) {
726              //   this.footer.onClick('first');
727              }
728          },
729         rowdblclick : function (_self, rowIndex, e)
730          {
731              if (!_this.dialog) return;
732              _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
733                  _this.grid.footer.onClick('first');
734              }); 
735          }
736        },
737        items : [
738
739        ]
740
741       },
742       '|xns' : 'Roo',
743       background : false,
744       fitContainer : true,
745       fitToFrame : true,
746       region : 'center',
747       tableName : 'core_notify_recur',
748       title : _this._strings['c7179f16884513c990b6cbf44aef7fc3'],
749       xns : Roo,
750       xtype : 'GridPanel',
751       listeners : {
752        activate : function() {
753          _this.panel = this;
754             if (_this.grid) {
755         //        _this.grid.footer.onClick('first');
756             }
757         }
758       },
759       items : [
760
761       ]
762
763      }
764     ]
765
766    });
767  }
768 };