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 Pman.Dialog.CoreNotifyRecur = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             height : 500,
34             modal : true,
35             resizable : false,
36             title : "Modify Recurrent Notifications",
37             width : 800,
38             items : [
39                 {
40                     xtype: 'GridPanel',
41                     xns: Roo,
42                     listeners : {
43                         activate : function() {
44                             _this.panel = this;
45                             if (_this.grid) {
46                                 _this.grid.footer.onClick('first');
47                             }
48                         }
49                     },
50                     background : false,
51                     fitContainer : true,
52                     fitToFrame : true,
53                     region : 'center',
54                     tableName : 'core_notify_recur',
55                     title : "core_notify_recur",
56                     grid : {
57                         xtype: 'EditorGrid',
58                         xns: Roo.grid,
59                         listeners : {
60                             render : function() 
61                             {
62                                 _this.grid = this; 
63                                 //_this.dialog = Pman.Dialog.FILL_IN
64                                 if (_this.panel.active) {
65                                    this.footer.onClick('first');
66                                 }
67                             },
68                             rowdblclick : function (_self, rowIndex, e)
69                             {
70                                 if (!_this.dialog) return;
71                                 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
72                                     _this.grid.footer.onClick('first');
73                                 }); 
74                             },
75                             afteredit : function (e)
76                             {
77                                e.record.commit();
78                             }
79                         },
80                         autoExpandColumn : 'freq_day',
81                         clicksToEdit : 1,
82                         loadMask : true,
83                         dataSource : {
84                             xtype: 'Store',
85                             xns: Roo.data,
86                             listeners : {
87                                 update : function (_self, record, operation)
88                                 {
89                                     Roo.log(operation);
90                                     if (operation != 'commit') {
91                                         return;
92                                     }
93                                     new Pman.Request({
94                                         url : baseURL + '/Roo/Core_notify_recur',
95                                         method :'POST',
96                                         params : record.data,
97                                         success : function()
98                                         {
99                                             //??
100                                         },
101                                         failure : function() {
102                                             Roo.MessageBox.alert("Error", "There was a problem saving");
103                                         }
104                                     });
105                                        
106                                     
107                                     
108                                 },
109                                 beforeload : function (_self, o)
110                                 {
111                                     o.params =  Roo.apply(o.params, {
112                                         person_id : _this.data.person_id,
113                                         onid : _this.data.onid,
114                                         ontable : _this.data.ontable,
115                                         method : _this.data.method
116                                     });
117                                         
118                                 }
119                             },
120                             remoteSort : true,
121                             sortInfo : { field : 'freq', direction: 'ASC' },
122                             proxy : {
123                                 xtype: 'HttpProxy',
124                                 xns: Roo.data,
125                                 method : 'GET',
126                                 url : baseURL + '/Roo/core_notify_recur.php'
127                             },
128                             reader : {
129                                 xtype: 'JsonReader',
130                                 xns: Roo.data,
131                                 id : 'id',
132                                 root : 'data',
133                                 totalProperty : 'total',
134                                 fields : [
135                                     {
136                                         'name': 'id',
137                                         'type': 'int'
138                                     },
139                                     {
140                                         'name': 'person_id',
141                                         'type': 'int'
142                                     },
143                                     {
144                                         'name': 'dtstart',
145                                         'type': 'date',
146                                         'dateFormat': 'Y-m-d'
147                                     },
148                                     {
149                                         'name': 'dtend',
150                                         'type': 'date',
151                                         'dateFormat': 'Y-m-d'
152                                     },
153                                     {
154                                         'name': 'tz',
155                                         'type': 'float'
156                                     },
157                                     {
158                                         'name': 'last_applied_dt',
159                                         'type': 'date',
160                                         'dateFormat': 'Y-m-d'
161                                     },
162                                     {
163                                         'name': 'freq',
164                                         'type': 'string'
165                                     },
166                                     {
167                                         'name': 'freq_day',
168                                         'type': 'string'
169                                     },
170                                     {
171                                         'name': 'freq_hour',
172                                         'type': 'string'
173                                     },
174                                     {
175                                         'name': 'last_event_id',
176                                         'type': 'int'
177                                     },
178                                     {
179                                         'name': 'method',
180                                         'type': 'string'
181                                     }
182                                 ]
183                             }
184                         },
185                         footer : {
186                             xtype: 'PagingToolbar',
187                             xns: Roo,
188                             pageSize : 25,
189                             displayInfo : true,
190                             displayMsg : "Displaying core_notify_recur{0} - {1} of {2}",
191                             emptyMsg : "No core_notify_recur found"
192                         },
193                         toolbar : {
194                             xtype: 'Toolbar',
195                             xns: Roo,
196                             items : [
197                                 {
198                                     xtype: 'Button',
199                                     xns: Roo.Toolbar,
200                                     listeners : {
201                                         click : function()
202                                         {
203                                             var grid = _this.grid;
204                                             var r = grid.getDataSource().reader.newRow({
205                                             // defaults..
206                                                 person_id : _this.data.person_id,
207                                                 dtstart : new Date(0),
208                                                 dtend : Date.parseDate('2050-01-01', 'Y-m-d'),
209                                                 tz : 'Asia/Hong Kong',
210                                                 onid : _this.data.onid,
211                                                 ontable : _this.data.ontable,
212                                                 method : _this.data.method,
213                                                 last_event_id : 0,
214                                                 freq_day_name : '',
215                                                 freq_hour_name : '',
216                                                 freq_name : ''
217                                                 
218                                             
219                                             });
220                                             grid.stopEditing();
221                                             grid.getDataSource().insert(0, r); 
222                                             grid.startEditing(0, 2); 
223                                             
224                                         
225                                         }
226                                     },
227                                     cls : 'x-btn-text-icon',
228                                     text : "Add",
229                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
230                                 },
231                                 {
232                                     xtype: 'Fill',
233                                     xns: Roo.Toolbar
234                                 },
235                                 {
236                                     xtype: 'Button',
237                                     xns: Roo.Toolbar,
238                                     text : "Delete",
239                                     cls : 'x-btn-text-icon',
240                                     icon : rootURL + '/Pman/templates/images/trash.gif',
241                                     listeners : {
242                                         click : function()
243                                         {
244                                              Pman.genericDelete(_this, 'core_notify_recur'); 
245                                         }
246                                     }
247                                 }
248                             ]
249                         },
250                         colModel : [
251                             {
252                                 xtype: 'ColumnModel',
253                                 xns: Roo.grid,
254                                 dataIndex : 'dtstart',
255                                 header : 'From',
256                                 width : 75,
257                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
258                                 editor : {
259                                     xtype: 'GridEditor',
260                                     xns: Roo.grid,
261                                     field : {
262                                         xtype: 'DateField',
263                                         xns: Roo.form
264                                     }
265                                 }
266                             },
267                             {
268                                 xtype: 'ColumnModel',
269                                 xns: Roo.grid,
270                                 dataIndex : 'dtend',
271                                 header : 'Until',
272                                 width : 75,
273                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
274                                 editor : {
275                                     xtype: 'GridEditor',
276                                     xns: Roo.grid,
277                                     field : {
278                                         xtype: 'DateField',
279                                         xns: Roo.form
280                                     }
281                                 }
282                             },
283                             {
284                                 xtype: 'ColumnModel',
285                                 xns: Roo.grid,
286                                 dataIndex : 'freq_day',
287                                 header : 'on day(s)',
288                                 width : 100,
289                                 renderer : function(v,x,r) { 
290                                     
291                                     return String.format('{0}', r.data.freq_day_name || v); 
292                                     
293                                 },
294                                 editor : {
295                                     xtype: 'GridEditor',
296                                     xns: Roo.grid,
297                                     field : {
298                                         xtype: 'ComboCheck',
299                                         xns: Roo.form,
300                                         allowBlank : false,
301                                         displayField : 'title',
302                                         editable : false,
303                                         fieldLabel : 'Country',
304                                         hiddenName : 'freq_day',
305                                         listWidth : 300,
306                                         mode : 'local',
307                                         name : 'freq_day_name',
308                                         pageSize : 40,
309                                         triggerAction : 'all',
310                                         valueField : 'code',
311                                         store : {
312                                             xtype: 'SimpleStore',
313                                             xns: Roo.data,
314                                             data : (function() { 
315                                                 var ret = [];
316                                                 Roo.each(Date.dayNames, function(d) {
317                                                     ret.push([ d.substring(0,3).toUpperCase(), d ]);
318                                                 });
319                                                 return ret;
320                                             })(),
321                                             fields : ['code', 'title'],
322                                             sortInfo : { field : 'title', direction: 'ASC' }
323                                         }
324                                     }
325                                 }
326                             },
327                             {
328                                 xtype: 'ColumnModel',
329                                 xns: Roo.grid,
330                                 dataIndex : 'freq_hour',
331                                 header : 'at Hour(s)',
332                                 width : 250,
333                                 renderer : function(v,x,r) { 
334                                     
335                                     return String.format('{0}', r.data.freq_hour_name || v); 
336                                     
337                                 },
338                                 editor : {
339                                     xtype: 'GridEditor',
340                                     xns: Roo.grid,
341                                     field : {
342                                         xtype: 'ComboCheck',
343                                         xns: Roo.form,
344                                         allowBlank : false,
345                                         displayField : 'title',
346                                         editable : false,
347                                         fieldLabel : 'Country',
348                                         hiddenName : 'freq_hour',
349                                         listWidth : 300,
350                                         mode : 'local',
351                                         name : 'freq_hour_name',
352                                         pageSize : 40,
353                                         triggerAction : 'all',
354                                         valueField : 'code',
355                                         store : {
356                                             xtype: 'SimpleStore',
357                                             xns: Roo.data,
358                                             data : (function() { 
359                                                 var ret = [];
360                                                 for (var i = 5; i < 25; i++) {
361                                                     var h = i < 10 ? ('0' + i) : i;
362                                                     var mer = i < 12 || i > 23 ? 'am' : 'pm';
363                                                     var dh = i < 13 ? i : i-12;
364                                                     
365                                                     ret.push([ h+':00', dh+':00' + mer ]);
366                                                     ret.push([ h+':00', dh+':30' + mer ]);        
367                                                 }
368                                                 return ret;
369                                             })(),
370                                             fields : ['code', 'title'],
371                                             sortInfo : { field : 'title', direction: 'ASC' }
372                                         }
373                                     }
374                                 }
375                             },
376                             {
377                                 xtype: 'ColumnModel',
378                                 xns: Roo.grid,
379                                 dataIndex : 'tz',
380                                 header : 'Timezone',
381                                 width : 100,
382                                 renderer : function(v) { return String.format('{0}', v); },
383                                 editor : {
384                                     xtype: 'GridEditor',
385                                     xns: Roo.grid,
386                                     field : {
387                                         xtype: 'ComboBox',
388                                         xns: Roo.form,
389                                         allowBlank : 'false',
390                                         displayField : 'tz',
391                                         editable : true,
392                                         emptyText : "Select timezone",
393                                         fieldLabel : 'core_enum',
394                                         forceSelection : true,
395                                         hiddenName : 'tz',
396                                         listWidth : 400,
397                                         loadingText : "Searching...",
398                                         minChars : 2,
399                                         name : 'tz_name',
400                                         pageSize : 999,
401                                         qtip : "Select timezone",
402                                         queryParam : 'q',
403                                         selectOnFocus : true,
404                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{tz}</b> </div>',
405                                         triggerAction : 'all',
406                                         typeAhead : true,
407                                         valueField : 'tz',
408                                         width : 300,
409                                         store : {
410                                             xtype: 'Store',
411                                             xns: Roo.data,
412                                             listeners : {
413                                                 beforeload : function (_self, o){
414                                                     o.params = o.params || {};
415                                                     // set more here
416                                                 }
417                                             },
418                                             remoteSort : true,
419                                             sortInfo : { direction : 'ASC', field: 'tz' },
420                                             proxy : {
421                                                 xtype: 'HttpProxy',
422                                                 xns: Roo.data,
423                                                 method : 'GET',
424                                                 url : baseURL + '/Core/I18n/Timezone.php'
425                                             },
426                                             reader : {
427                                                 xtype: 'JsonReader',
428                                                 xns: Roo.data,
429                                                 id : 'id',
430                                                 root : 'data',
431                                                 totalProperty : 'total',
432                                                 fields : [{"name":"tz","type":"string"}]
433                                             }
434                                         }
435                                     }
436                                 }
437                             },
438                             {
439                                 xtype: 'ColumnModel',
440                                 xns: Roo.grid,
441                                 header : 'Last event',
442                                 width : 75,
443                                 dataIndex : 'last_event_id',
444                                 renderer : function(v) { return String.format('{0}', v); }
445                             }
446                         ]
447                     }
448                 }
449             ],
450             center : {
451                 xtype: 'LayoutRegion',
452                 xns: Roo,
453                 autoScroll : true,
454                 loadOnce : true
455             },
456             buttons : [
457                 {
458                     xtype: 'Button',
459                     xns: Roo,
460                     text : "Done"
461                 }
462             ]
463         });
464     }
465 };