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