ad6b3adb57a208ad84d23c53f5e86184cbda49f0
[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                                                 
177                                             
178                                             });
179                                             grid.stopEditing();
180                                             grid.getDataSource().insert(0, r); 
181                                             grid.startEditing(0, 2); 
182                                         
183                                         }
184                                     },
185                                     cls : 'x-btn-text-icon',
186                                     text : "Add",
187                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
188                                 },
189                                 {
190                                     xtype: 'Fill',
191                                     xns: Roo.Toolbar
192                                 },
193                                 {
194                                     xtype: 'Button',
195                                     xns: Roo.Toolbar,
196                                     text : "Delete",
197                                     cls : 'x-btn-text-icon',
198                                     icon : rootURL + '/Pman/templates/images/trash.gif',
199                                     listeners : {
200                                         click : function()
201                                         {
202                                              Pman.genericDelete(_this, 'core_notify_recur'); 
203                                         }
204                                     }
205                                 }
206                             ]
207                         },
208                         colModel : [
209                             {
210                                 xtype: 'ColumnModel',
211                                 xns: Roo.grid,
212                                 dataIndex : 'dtstart',
213                                 header : 'From',
214                                 width : 75,
215                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
216                                 editor : {
217                                     xtype: 'GridEditor',
218                                     xns: Roo.grid,
219                                     field : {
220                                         xtype: 'DateField',
221                                         xns: Roo.form
222                                     }
223                                 }
224                             },
225                             {
226                                 xtype: 'ColumnModel',
227                                 xns: Roo.grid,
228                                 dataIndex : 'dtend',
229                                 header : 'Until',
230                                 width : 75,
231                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
232                                 editor : {
233                                     xtype: 'GridEditor',
234                                     xns: Roo.grid,
235                                     field : {
236                                         xtype: 'DateField',
237                                         xns: Roo.form
238                                     }
239                                 }
240                             },
241                             {
242                                 xtype: 'ColumnModel',
243                                 xns: Roo.grid,
244                                 dataIndex : 'freq',
245                                 header : 'Frequency',
246                                 width : 70,
247                                 renderer : function(v,x,r) { 
248                                 
249                                     Roo.log(this);
250                                     var cm = _this.grid.colModel;
251                                     var ix = cm.findColumnIndex('freq');
252                                     var ce = cm.getCellEditor(ix)
253                                     var matches = ce.field.store.query('code',v);
254                                     if (!matches.length) {
255                                         return '';
256                                     }
257                                     return String.format('{0}', matches.first().data.title);
258                                  },
259                                 editor : {
260                                     xtype: 'GridEditor',
261                                     xns: Roo.grid,
262                                     field : {
263                                         xtype: 'ComboBox',
264                                         xns: Roo.form,
265                                         allowBlank : false,
266                                         displayField : 'title',
267                                         editable : false,
268                                         fieldLabel : 'Country',
269                                         hiddenName : 'freq',
270                                         listWidth : 200,
271                                         mode : 'local',
272                                         name : 'freq_name',
273                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{title}</b> </div>',
274                                         triggerAction : 'all',
275                                         valueField : 'code',
276                                         width : 200,
277                                         store : {
278                                             xtype: 'SimpleStore',
279                                             xns: Roo.data,
280                                             data : [ 
281                                                 [ 'HOURLY' , 'Hourly at' ] ,
282                                                    [ 'DAILY' , 'Daily at'] ,
283                                                     [ 'WEEKLY' , 'Weekly at'] ,
284                                                      [ 'Montly' , 'Montly at'] 
285                                             ],
286                                             fields : ['code', 'title'],
287                                             sortInfo : { field : 'title', direction: 'ASC' }
288                                         }
289                                     }
290                                 }
291                             },
292                             {
293                                 xtype: 'ColumnModel',
294                                 xns: Roo.grid,
295                                 dataIndex : 'freq_day',
296                                 header : 'on day(s)',
297                                 width : 100,
298                                 renderer : function(v) { return String.format('{0}', v); },
299                                 editor : {
300                                     xtype: 'GridEditor',
301                                     xns: Roo.grid,
302                                     field : {
303                                         xtype: 'ComboCheck',
304                                         xns: Roo.form,
305                                         allowBlank : false,
306                                         displayField : 'title',
307                                         editable : false,
308                                         fieldLabel : 'Country',
309                                         hiddenName : 'freq_day',
310                                         listWidth : 300,
311                                         mode : 'local',
312                                         name : 'freq_name',
313                                         pageSize : 40,
314                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{title}</b> </div>',
315                                         triggerAction : 'all',
316                                         valueField : 'code',
317                                         store : {
318                                             xtype: 'SimpleStore',
319                                             xns: Roo.data,
320                                             data : (function() { 
321                                                 var ret = [];
322                                                 Roo.each(Date.dayNames, function(d) {
323                                                     ret.push([ d.substring(0,3).toUpperCase(), d ]);
324                                                 });
325                                                 return ret;
326                                             })(),
327                                             fields : ['code', 'title'],
328                                             sortInfo : { field : 'title', direction: 'ASC' }
329                                         }
330                                     }
331                                 }
332                             },
333                             {
334                                 xtype: 'ColumnModel',
335                                 xns: Roo.grid,
336                                 dataIndex : 'freq_hour',
337                                 header : 'at Hour(s)',
338                                 width : 250,
339                                 renderer : function(v) { return String.format('{0}', v); },
340                                 editor : {
341                                     xtype: 'GridEditor',
342                                     xns: Roo.grid,
343                                     field : {
344                                         xtype: 'ComboCheck',
345                                         xns: Roo.form,
346                                         allowBlank : false,
347                                         displayField : 'title',
348                                         editable : false,
349                                         fieldLabel : 'Country',
350                                         hiddenName : 'freq_hour',
351                                         listWidth : 300,
352                                         mode : 'local',
353                                         name : 'freq_hour_name',
354                                         pageSize : 40,
355                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{title}</b> </div>',
356                                         triggerAction : 'all',
357                                         valueField : 'code',
358                                         store : {
359                                             xtype: 'SimpleStore',
360                                             xns: Roo.data,
361                                             data : (function() { 
362                                                 var ret = [];
363                                                 for (var i = 5; i < 25; i++) {
364                                                     var h = i < 10 ? ('0' + i) : i;
365                                                     var mer = i < 12 || i > 23 ? 'am' : 'pm';
366                                                     var dh = i < 12 ? i : i-12;
367                                                     
368                                                     ret.push([ h+':00', dh+':00' + mer ]);
369                                                     ret.push([ h+':00', dh+':30' + mer ]);        
370                                                 }
371                                                 return ret;
372                                             })(),
373                                             fields : ['code', 'title'],
374                                             sortInfo : { field : 'title', direction: 'ASC' }
375                                         }
376                                     }
377                                 }
378                             },
379                             {
380                                 xtype: 'ColumnModel',
381                                 xns: Roo.grid,
382                                 dataIndex : 'tz',
383                                 header : 'Timezone',
384                                 width : 100,
385                                 renderer : function(v) { return String.format('{0}', v); }
386                             },
387                             {
388                                 xtype: 'ColumnModel',
389                                 xns: Roo.grid,
390                                 header : 'Last event',
391                                 width : 75,
392                                 dataIndex : 'last_event_id',
393                                 renderer : function(v) { return String.format('{0}', v); }
394                             }
395                         ]
396                     }
397                 }
398             ],
399             center : {
400                 xtype: 'LayoutRegion',
401                 xns: Roo,
402                 autoScroll : true,
403                 loadOnce : true
404             },
405             buttons : [
406                 {
407                     xtype: 'Button',
408                     xns: Roo,
409                     text : "Done"
410                 }
411             ]
412         });
413     }
414 };