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