d48064ad03a84a6c5016ff20356627fae089b978
[Pman.Core] / Pman.Dialog.CoreNotifyRefer.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.CoreNotifyRefer = {
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                         },
76                         autoExpandColumn : 'freq_day',
77                         clicksToEdit : 1,
78                         loadMask : true,
79                         dataSource : {
80                             xtype: 'Store',
81                             xns: Roo.data,
82                             remoteSort : true,
83                             sortInfo : { field : 'freq', direction: 'ASC' },
84                             proxy : {
85                                 xtype: 'HttpProxy',
86                                 xns: Roo.data,
87                                 method : 'GET',
88                                 url : baseURL + '/Roo/core_notify_recur.php'
89                             },
90                             reader : {
91                                 xtype: 'JsonReader',
92                                 xns: Roo.data,
93                                 id : 'id',
94                                 root : 'data',
95                                 totalProperty : 'total',
96                                 fields : [
97                                     {
98                                         'name': 'id',
99                                         'type': 'int'
100                                     },
101                                     {
102                                         'name': 'person_id',
103                                         'type': 'int'
104                                     },
105                                     {
106                                         'name': 'dtstart',
107                                         'type': 'date',
108                                         'dateFormat': 'Y-m-d'
109                                     },
110                                     {
111                                         'name': 'dtend',
112                                         'type': 'date',
113                                         'dateFormat': 'Y-m-d'
114                                     },
115                                     {
116                                         'name': 'tz',
117                                         'type': 'float'
118                                     },
119                                     {
120                                         'name': 'last_applied_dt',
121                                         'type': 'date',
122                                         'dateFormat': 'Y-m-d'
123                                     },
124                                     {
125                                         'name': 'freq',
126                                         'type': 'string'
127                                     },
128                                     {
129                                         'name': 'freq_day',
130                                         'type': 'string'
131                                     },
132                                     {
133                                         'name': 'freq_hour',
134                                         'type': 'string'
135                                     },
136                                     {
137                                         'name': 'last_event_id',
138                                         'type': 'int'
139                                     },
140                                     {
141                                         'name': 'method',
142                                         'type': 'string'
143                                     }
144                                 ]
145                             }
146                         },
147                         footer : {
148                             xtype: 'PagingToolbar',
149                             xns: Roo,
150                             pageSize : 25,
151                             displayInfo : true,
152                             displayMsg : "Displaying core_notify_recur{0} - {1} of {2}",
153                             emptyMsg : "No core_notify_recur found"
154                         },
155                         toolbar : {
156                             xtype: 'Toolbar',
157                             xns: Roo,
158                             items : [
159                                 {
160                                     xtype: 'Button',
161                                     xns: Roo.Toolbar,
162                                     listeners : {
163                                         click : function()
164                                         {
165                                             var grid = _this.grid;
166                                             var r = grid.getDataSource().reader.newRow({
167                                             // defaults..
168                                                 person_id : _this.data.person_id,
169                                                 dtstart : new Date(0),
170                                                 dtend : Date.parseDate('2050-01-01', 'Y-m-d'),
171                                                 tz : 'Asia/Hong Kong',
172                                                 onid : _this.data.onid,
173                                                 ontable : _this.data.ontable,
174                                                 method : _this.data.method,
175                                                 last_event_id : 0,
176                                                 freq_day_name : '',
177                                                 freq_hour_name : '',
178                                                 freq_name : ''
179                                                 
180                                             
181                                             });
182                                             grid.stopEditing();
183                                             grid.getDataSource().insert(0, r); 
184                                             grid.startEditing(0, 2); 
185                                         
186                                         }
187                                     },
188                                     cls : 'x-btn-text-icon',
189                                     text : "Add",
190                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
191                                 },
192                                 {
193                                     xtype: 'Fill',
194                                     xns: Roo.Toolbar
195                                 },
196                                 {
197                                     xtype: 'Button',
198                                     xns: Roo.Toolbar,
199                                     text : "Delete",
200                                     cls : 'x-btn-text-icon',
201                                     icon : rootURL + '/Pman/templates/images/trash.gif',
202                                     listeners : {
203                                         click : function()
204                                         {
205                                              Pman.genericDelete(_this, 'core_notify_recur'); 
206                                         }
207                                     }
208                                 }
209                             ]
210                         },
211                         colModel : [
212                             {
213                                 xtype: 'ColumnModel',
214                                 xns: Roo.grid,
215                                 dataIndex : 'dtstart',
216                                 header : 'From',
217                                 width : 75,
218                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
219                                 editor : {
220                                     xtype: 'GridEditor',
221                                     xns: Roo.grid,
222                                     field : {
223                                         xtype: 'DateField',
224                                         xns: Roo.form
225                                     }
226                                 }
227                             },
228                             {
229                                 xtype: 'ColumnModel',
230                                 xns: Roo.grid,
231                                 dataIndex : 'dtend',
232                                 header : 'Until',
233                                 width : 75,
234                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
235                                 editor : {
236                                     xtype: 'GridEditor',
237                                     xns: Roo.grid,
238                                     field : {
239                                         xtype: 'DateField',
240                                         xns: Roo.form
241                                     }
242                                 }
243                             },
244                             {
245                                 xtype: 'ColumnModel',
246                                 xns: Roo.grid,
247                                 dataIndex : 'freq',
248                                 header : 'Frequency',
249                                 width : 70,
250                                 renderer : function(v,x,r) { 
251                                 
252                                     Roo.log(this);
253                                     var cm = _this.grid.colModel;
254                                     var ix = cm.findColumnIndex('freq');
255                                     var ce = cm.getCellEditor(ix)
256                                     var matches = ce.field.store.query('code',v);
257                                     if (!matches.length) {
258                                         return '';
259                                     }
260                                     return String.format('{0}', matches.first().data.title);
261                                  },
262                                 editor : {
263                                     xtype: 'GridEditor',
264                                     xns: Roo.grid,
265                                     field : {
266                                         xtype: 'ComboBox',
267                                         xns: Roo.form,
268                                         allowBlank : false,
269                                         displayField : 'title',
270                                         editable : false,
271                                         fieldLabel : 'Country',
272                                         hiddenName : 'freq',
273                                         listWidth : 200,
274                                         mode : 'local',
275                                         name : 'freq_name',
276                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{title}</b> </div>',
277                                         triggerAction : 'all',
278                                         valueField : 'code',
279                                         width : 200,
280                                         store : {
281                                             xtype: 'SimpleStore',
282                                             xns: Roo.data,
283                                             data : [ 
284                                                 [ 'HOURLY' , 'Hourly at' ] ,
285                                                    [ 'DAILY' , 'Daily at'] ,
286                                                     [ 'WEEKLY' , 'Weekly at'] ,
287                                                      [ 'Montly' , 'Montly at'] 
288                                             ],
289                                             fields : ['code', 'title'],
290                                             sortInfo : { field : 'title', direction: 'ASC' }
291                                         }
292                                     }
293                                 }
294                             },
295                             {
296                                 xtype: 'ColumnModel',
297                                 xns: Roo.grid,
298                                 dataIndex : 'freq_day',
299                                 header : 'on day(s)',
300                                 width : 100,
301                                 renderer : function(v) { return String.format('{0}', v); },
302                                 editor : {
303                                     xtype: 'GridEditor',
304                                     xns: Roo.grid,
305                                     field : {
306                                         xtype: 'ComboCheck',
307                                         xns: Roo.form,
308                                         allowBlank : false,
309                                         displayField : 'title',
310                                         editable : false,
311                                         fieldLabel : 'Country',
312                                         hiddenName : 'freq_day',
313                                         listWidth : 300,
314                                         mode : 'local',
315                                         name : 'freq_day_name',
316                                         pageSize : 40,
317                                         triggerAction : 'all',
318                                         valueField : 'code',
319                                         store : {
320                                             xtype: 'SimpleStore',
321                                             xns: Roo.data,
322                                             data : (function() { 
323                                                 var ret = [];
324                                                 Roo.each(Date.dayNames, function(d) {
325                                                     ret.push([ d.substring(0,3).toUpperCase(), d ]);
326                                                 });
327                                                 return ret;
328                                             })(),
329                                             fields : ['code', 'title'],
330                                             sortInfo : { field : 'title', direction: 'ASC' }
331                                         }
332                                     }
333                                 }
334                             },
335                             {
336                                 xtype: 'ColumnModel',
337                                 xns: Roo.grid,
338                                 dataIndex : 'freq_hour',
339                                 header : 'at Hour(s)',
340                                 width : 250,
341                                 renderer : function(v) { return String.format('{0}', v); },
342                                 editor : {
343                                     xtype: 'GridEditor',
344                                     xns: Roo.grid,
345                                     field : {
346                                         xtype: 'ComboCheck',
347                                         xns: Roo.form,
348                                         allowBlank : false,
349                                         displayField : 'title',
350                                         editable : false,
351                                         fieldLabel : 'Country',
352                                         hiddenName : 'freq_hour',
353                                         listWidth : 300,
354                                         mode : 'local',
355                                         name : 'freq_hour_name',
356                                         pageSize : 40,
357                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{title}</b> </div>',
358                                         triggerAction : 'all',
359                                         valueField : 'code',
360                                         store : {
361                                             xtype: 'SimpleStore',
362                                             xns: Roo.data,
363                                             data : (function() { 
364                                                 var ret = [];
365                                                 for (var i = 5; i < 25; i++) {
366                                                     var h = i < 10 ? ('0' + i) : i;
367                                                     var mer = i < 12 || i > 23 ? 'am' : 'pm';
368                                                     var dh = i < 12 ? i : i-12;
369                                                     
370                                                     ret.push([ h+':00', dh+':00' + mer ]);
371                                                     ret.push([ h+':00', dh+':30' + mer ]);        
372                                                 }
373                                                 return ret;
374                                             })(),
375                                             fields : ['code', 'title'],
376                                             sortInfo : { field : 'title', direction: 'ASC' }
377                                         }
378                                     }
379                                 }
380                             },
381                             {
382                                 xtype: 'ColumnModel',
383                                 xns: Roo.grid,
384                                 dataIndex : 'tz',
385                                 header : 'Timezone',
386                                 width : 100,
387                                 renderer : function(v) { return String.format('{0}', v); }
388                             },
389                             {
390                                 xtype: 'ColumnModel',
391                                 xns: Roo.grid,
392                                 header : 'Last event',
393                                 width : 75,
394                                 dataIndex : 'last_event_id',
395                                 renderer : function(v) { return String.format('{0}', v); }
396                             }
397                         ]
398                     }
399                 }
400             ],
401             center : {
402                 xtype: 'LayoutRegion',
403                 xns: Roo,
404                 autoScroll : true,
405                 loadOnce : true
406             },
407             buttons : [
408                 {
409                     xtype: 'Button',
410                     xns: Roo,
411                     text : "Done"
412                 }
413             ]
414         });
415     }
416 };