check file exists
[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    "xtype" : "LayoutDialog",
33    "title" : "Modify Recurrent Notifications",
34    "width" : 800,
35    "$ xns" : "Roo",
36    "resizable" : true,
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      "region" : "center",
51      "fitToFrame" : true,
52      "background" : false,
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         "|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}",
62         "afteredit" : "function (e)\n{\n   e.record.commit();\n}"
63        },
64        "autoExpandColumn" : "freq_day",
65        "xtype" : "EditorGrid",
66        "loadMask" : true,
67        "clicksToEdit" : 1,
68        "$ xns" : "Roo.grid",
69        "* prop" : "grid",
70        "items" : [
71         {
72          "listeners" : {
73           "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}",
74           "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}"
75          },
76          "xtype" : "Store",
77          "remoteSort" : true,
78          "$ sortInfo" : "{ field : 'freq', direction: 'ASC' }",
79          "$ xns" : "Roo.data",
80          "* prop" : "dataSource",
81          "items" : [
82           {
83            "$ url" : "baseURL + '/Roo/core_notify_recur.php'",
84            "xtype" : "HttpProxy",
85            "method" : "GET",
86            "$ xns" : "Roo.data",
87            "* prop" : "proxy"
88           },
89           {
90            "id" : "id",
91            "root" : "data",
92            "xtype" : "JsonReader",
93            "$ 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]",
94            "$ xns" : "Roo.data",
95            "* prop" : "reader",
96            "totalProperty" : "total"
97           }
98          ]
99         },
100         {
101          "xtype" : "Toolbar",
102          "$ xns" : "Roo",
103          "* prop" : "toolbar",
104          "items" : [
105           {
106            "listeners" : {
107             "|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"
108            },
109            "text" : "Add",
110            "xtype" : "Button",
111            "cls" : "x-btn-text-icon",
112            "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
113            "$ xns" : "Roo.Toolbar"
114           },
115           {
116            "xtype" : "Fill",
117            "$ xns" : "Roo.Toolbar"
118           },
119           {
120            "listeners" : {
121             "|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        "
122            },
123            "text" : "Delete",
124            "xtype" : "Button",
125            "cls" : "x-btn-text-icon",
126            "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
127            "$ xns" : "Roo.Toolbar"
128           }
129          ]
130         },
131         {
132          "xtype" : "ColumnModel",
133          "width" : 120,
134          "header" : "Type",
135          "$ renderer" : "function(v,x,r) {\n     return String.format('{0}', r.data.method_id_display_name); \n}",
136          "$ xns" : "Roo.grid",
137          "* prop" : "colModel[]",
138          "dataIndex" : "method_id",
139          "items" : [
140           {
141            "xtype" : "GridEditor",
142            "$ xns" : "Roo.grid",
143            "* prop" : "editor",
144            "items" : [
145             {
146              "listWidth" : 400,
147              "triggerAction" : "all",
148              "fieldLabel" : "core_enum",
149              "forceSelection" : true,
150              "selectOnFocus" : true,
151              "pageSize" : 20,
152              "displayField" : "display_name",
153              "emptyText" : "Select Type",
154              "hiddenName" : "method_id",
155              "valueField" : "id",
156              "xtype" : "ComboBox",
157              "allowBlank" : false,
158              "typeAhead" : true,
159              "editable" : false,
160              "width" : 300,
161              "$ xns" : "Roo.form",
162              "* prop" : "field",
163              "name" : "method_id_display_name",
164              "qtip" : "Select core_enum",
165              "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>",
166              "loadingText" : "Searching...",
167              "items" : [
168               {
169                "listeners" : {
170                 "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    o.params.etype = 'core_notify_recur';\n}\n"
171                },
172                "xtype" : "Store",
173                "remoteSort" : true,
174                "$ sortInfo" : "{ direction : 'ASC', field: 'id' }",
175                "$ xns" : "Roo.data",
176                "* prop" : "store",
177                "items" : [
178                 {
179                  "$ url" : "baseURL + '/Roo/core_enum.php'",
180                  "xtype" : "HttpProxy",
181                  "method" : "GET",
182                  "$ xns" : "Roo.data",
183                  "* prop" : "proxy"
184                 },
185                 {
186                  "id" : "id",
187                  "root" : "data",
188                  "xtype" : "JsonReader",
189                  "$ xns" : "Roo.data",
190                  "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"etype\",\"type\":\"string\"}]",
191                  "* prop" : "reader",
192                  "totalProperty" : "total"
193                 }
194                ]
195               }
196              ]
197             }
198            ]
199           }
200          ]
201         },
202         {
203          "xtype" : "ColumnModel",
204          "width" : 75,
205          "header" : "From",
206          "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
207          "$ xns" : "Roo.grid",
208          "* prop" : "colModel[]",
209          "dataIndex" : "dtstart",
210          "items" : [
211           {
212            "xtype" : "GridEditor",
213            "$ xns" : "Roo.grid",
214            "* prop" : "editor",
215            "items" : [
216             {
217              "xtype" : "DateField",
218              "$ xns" : "Roo.form",
219              "* prop" : "field"
220             }
221            ]
222           }
223          ]
224         },
225         {
226          "xtype" : "ColumnModel",
227          "width" : 75,
228          "header" : "Until",
229          "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
230          "$ xns" : "Roo.grid",
231          "* prop" : "colModel[]",
232          "dataIndex" : "dtend",
233          "items" : [
234           {
235            "xtype" : "GridEditor",
236            "$ xns" : "Roo.grid",
237            "* prop" : "editor",
238            "items" : [
239             {
240              "xtype" : "DateField",
241              "$ xns" : "Roo.form",
242              "* prop" : "field"
243             }
244            ]
245           }
246          ]
247         },
248         {
249          "xtype" : "ColumnModel",
250          "width" : 150,
251          "header" : "on day(s)",
252          "$ 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}",
253          "$ xns" : "Roo.grid",
254          "* prop" : "colModel[]",
255          "dataIndex" : "freq_day",
256          "items" : [
257           {
258            "xtype" : "GridEditor",
259            "$ xns" : "Roo.grid",
260            "* prop" : "editor",
261            "items" : [
262             {
263              "listWidth" : 300,
264              "triggerAction" : "all",
265              "fieldLabel" : "Country",
266              "pageSize" : 40,
267              "displayField" : "title",
268              "hiddenName" : "freq_day",
269              "valueField" : "code",
270              "xtype" : "ComboCheck",
271              "allowBlank" : false,
272              "editable" : false,
273              "$ xns" : "Roo.form",
274              "* prop" : "field",
275              "mode" : "local",
276              "name" : "freq_day_name",
277              "items" : [
278               {
279                "| 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})()",
280                "xtype" : "SimpleStore",
281                "$ fields" : "['code', 'title']",
282                "$ sortInfo" : "{ field : 'title', direction: 'ASC' }",
283                "$ xns" : "Roo.data",
284                "* prop" : "store"
285               }
286              ]
287             }
288            ]
289           }
290          ]
291         },
292         {
293          "xtype" : "ColumnModel",
294          "width" : 100,
295          "header" : "at Hour(s)",
296          "$ 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}",
297          "$ xns" : "Roo.grid",
298          "* prop" : "colModel[]",
299          "dataIndex" : "freq_hour",
300          "items" : [
301           {
302            "xtype" : "GridEditor",
303            "$ xns" : "Roo.grid",
304            "* prop" : "editor",
305            "items" : [
306             {
307              "listWidth" : 300,
308              "triggerAction" : "all",
309              "fieldLabel" : "Country",
310              "pageSize" : 40,
311              "displayField" : "title",
312              "hiddenName" : "freq_hour",
313              "valueField" : "code",
314              "xtype" : "ComboCheck",
315              "allowBlank" : false,
316              "editable" : false,
317              "$ xns" : "Roo.form",
318              "* prop" : "field",
319              "mode" : "local",
320              "name" : "freq_hour_name",
321              "items" : [
322               {
323                "| 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})()",
324                "xtype" : "SimpleStore",
325                "$ fields" : "['code', 'title']",
326                "$ sortInfo" : "{ field : 'title', direction: 'ASC' }",
327                "$ xns" : "Roo.data",
328                "* prop" : "store"
329               }
330              ]
331             }
332            ]
333           }
334          ]
335         },
336         {
337          "xtype" : "ColumnModel",
338          "width" : 100,
339          "header" : "Timezone",
340          "$ renderer" : "function(v) { return String.format('{0}', v); }",
341          "$ xns" : "Roo.grid",
342          "* prop" : "colModel[]",
343          "dataIndex" : "tz",
344          "items" : [
345           {
346            "xtype" : "GridEditor",
347            "$ xns" : "Roo.grid",
348            "* prop" : "editor",
349            "items" : [
350             {
351              "listWidth" : 400,
352              "triggerAction" : "all",
353              "fieldLabel" : "core_enum",
354              "forceSelection" : true,
355              "selectOnFocus" : true,
356              "pageSize" : 999,
357              "displayField" : "tz",
358              "emptyText" : "Select timezone",
359              "minChars" : 2,
360              "xtype" : "ComboBox",
361              "allowBlank" : false,
362              "typeAhead" : true,
363              "editable" : true,
364              "width" : 300,
365              "$ xns" : "Roo.form",
366              "* prop" : "field",
367              "name" : "tz",
368              "qtip" : "Select timezone",
369              "queryParam" : "q",
370              "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{tz}</b> </div>",
371              "loadingText" : "Searching...",
372              "items" : [
373               {
374                "listeners" : {
375                 "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
376                },
377                "xtype" : "Store",
378                "remoteSort" : true,
379                "$ sortInfo" : "{ direction : 'ASC', field: 'tz' }",
380                "$ xns" : "Roo.data",
381                "* prop" : "store",
382                "items" : [
383                 {
384                  "$ url" : "baseURL + '/Core/I18n/Timezone.php'\n",
385                  "method" : "GET",
386                  "xtype" : "HttpProxy",
387                  "$ xns" : "Roo.data",
388                  "* prop" : "proxy"
389                 },
390                 {
391                  "id" : "id",
392                  "root" : "data",
393                  "xtype" : "JsonReader",
394                  "$ fields" : "[{\"name\":\"tz\",\"type\":\"string\"}]",
395                  "$ xns" : "Roo.data",
396                  "* prop" : "reader",
397                  "totalProperty" : "total"
398                 }
399                ]
400               }
401              ]
402             }
403            ]
404           }
405          ]
406         },
407         {
408          "xtype" : "ColumnModel",
409          "header" : "Last Sent",
410          "width" : 75,
411          "$ renderer" : "function(v) { return String.format('{0}', v ? v : 'never'); }",
412          "$ xns" : "Roo.grid",
413          "* prop" : "colModel[]",
414          "dataIndex" : "last_event_id"
415         }
416        ]
417       }
418      ]
419     },
420     {
421      "listeners" : {
422       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n}"
423      },
424      "text" : "Done",
425      "xtype" : "Button",
426      "$ xns" : "Roo",
427      "* prop" : "buttons[]"
428     }
429    ]
430   }
431  ]
432 }