sync
[Pman.Admin] / Pman.Dialog.AdminWatch.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.AdminWatch = {
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             closable : false,
34             collapsible : false,
35             height : 230,
36             modal : true,
37             resizable : false,
38             title : "Edit / Create core_watch",
39             width : 500,
40             items : [
41                 {
42                     xtype: 'ContentPanel',
43                     xns: Roo,
44                     region : 'center',
45                     items : [
46                         {
47                             xtype: 'Form',
48                             xns: Roo.form,
49                             listeners : {
50                                 actioncomplete : function(_self,action)
51                                 {
52                                     if (action.type == 'setdata') {
53                                        //_this.dialog.el.mask("Loading");
54                                        if (_this.data.id) {
55                                            this.load({ method: 'GET', params: { '_id' : _this.data.id }});
56                                        }
57                                        return;
58                                     }
59                                     if (action.type == 'load') {
60                                          return;
61                                     }
62                                     if (action.type =='submit') {
63                                     
64                                             _this.dialog.hide();
65                                     
66                                          if (_this.callback) {
67                                             _this.callback.call(_this, _this.form.getValues());
68                                          }
69                                          _this.form.reset();
70                                          return;
71                                     }
72                                 },
73                                 rendered : function (form)
74                                 {
75                                     _this.form= form;
76                                 }
77                             },
78                             method : 'POST',
79                             style : 'margin:10px;',
80                             url : baseURL + '/Roo/core_watch.php',
81                             items : [
82                                 {
83                                     xtype: 'ComboBox',
84                                     xns: Roo.form,
85                                     listeners : {
86                                         select : function (combo, record, index)
87                                         {
88                                           _this.grid.footer.onClick('first');
89                                         },
90                                         render : function (_self)
91                                         {
92                                           _this.affectSel = _self;
93                                         }
94                                     },
95                                     allowBlank : true,
96                                     displayField : 'on_table',
97                                     editable : false,
98                                     emptyText : "Select Table",
99                                     fieldLabel : 'Table',
100                                     forceSelection : true,
101                                     listWidth : 300,
102                                     loadingText : "Searching...",
103                                     minChars : 2,
104                                     name : 'ontable',
105                                     pageSize : 20,
106                                     qtip : "Select Action",
107                                     queryParam : 'query[on_table]',
108                                     selectOnFocus : true,
109                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{on_table}</b> </div>',
110                                     triggerAction : 'all',
111                                     typeAhead : true,
112                                     valueField : 'action',
113                                     width : 150,
114                                     store : {
115                                         xtype: 'Store',
116                                         xns: Roo.data,
117                                         listeners : {
118                                             beforeload : function (_self, o)
119                                             {
120                                                 o.params = o.params || {};
121                                                 // staff can see all logs, other companies can only see their own.
122                                                 if ((typeof(Pman.Login) != 'undefined') && Pman.Login.authUser.company_id_comptype != 'OWNER') {
123                                                     o.params.company_id = Pman.Login.authUser.company_id;
124                                                 }
125                                                 o.params._distinct = 'on_table';
126                                                 o.params._columns ='on_table';
127                                             }
128                                         },
129                                         remoteSort : true,
130                                         sortInfo : { field : 'on_table' , direction : 'ASC' },
131                                         proxy : {
132                                             xtype: 'HttpProxy',
133                                             xns: Roo.data,
134                                             method : 'GET',
135                                             url : baseURL + '/Roo/Events.php'
136                                         },
137                                         reader : {
138                                             xtype: 'JsonReader',
139                                             xns: Roo.data,
140                                             totalProperty : 'total',
141                                             root : 'data',
142                                             id : 'id',
143                                             fields : [
144                                                 {
145                                                     'name': 'id',
146                                                     'type': 'int'
147                                                 },
148                                                 {
149                                                     'name': 'person_name',
150                                                     'type': 'string'
151                                                 },
152                                                 {
153                                                     'name': 'event_when',
154                                                     'type': 'date',
155                                                     'dateFormat': 'Y-m-d'
156                                                 },
157                                                 {
158                                                     'name': 'action',
159                                                     'type': 'string'
160                                                 },
161                                                 {
162                                                     'name': 'ipaddr',
163                                                     'type': 'string'
164                                                 },
165                                                 {
166                                                     'name': 'on_id',
167                                                     'type': 'int'
168                                                 },
169                                                 {
170                                                     'name': 'on_table',
171                                                     'type': 'string'
172                                                 },
173                                                 {
174                                                     'name': 'person_id',
175                                                     'type': 'int'
176                                                 },
177                                                 {
178                                                     'name': 'remarks',
179                                                     'type': 'string'
180                                                 },
181                                                 {
182                                                     'name': 'person_id_id',
183                                                     'type': 'int'
184                                                 },
185                                                 {
186                                                     'name': 'person_id_office_id',
187                                                     'type': 'int'
188                                                 },
189                                                 {
190                                                     'name': 'person_id_name',
191                                                     'type': 'string'
192                                                 },
193                                                 {
194                                                     'name': 'person_id_phone',
195                                                     'type': 'string'
196                                                 },
197                                                 {
198                                                     'name': 'person_id_fax',
199                                                     'type': 'string'
200                                                 },
201                                                 {
202                                                     'name': 'person_id_email',
203                                                     'type': 'string'
204                                                 },
205                                                 {
206                                                     'name': 'person_id_company_id',
207                                                     'type': 'int'
208                                                 },
209                                                 {
210                                                     'name': 'person_id_role',
211                                                     'type': 'string'
212                                                 },
213                                                 {
214                                                     'name': 'person_id_active',
215                                                     'type': 'int'
216                                                 },
217                                                 {
218                                                     'name': 'person_id_remarks',
219                                                     'type': 'string'
220                                                 },
221                                                 {
222                                                     'name': 'person_id_passwd',
223                                                     'type': 'string'
224                                                 },
225                                                 {
226                                                     'name': 'person_id_owner_id',
227                                                     'type': 'int'
228                                                 },
229                                                 {
230                                                     'name': 'person_id_lang',
231                                                     'type': 'string'
232                                                 },
233                                                 {
234                                                     'name': 'person_id_no_reset_sent',
235                                                     'type': 'int'
236                                                 },
237                                                 {
238                                                     'name': 'person_id_action_type',
239                                                     'type': 'string'
240                                                 },
241                                                 {
242                                                     'name': 'person_id_project_id',
243                                                     'type': 'int'
244                                                 },
245                                                 {
246                                                     'name': 'person_id_deleted_by',
247                                                     'type': 'int'
248                                                 },
249                                                 {
250                                                     'name': 'person_id_deleted_dt',
251                                                     'type': 'date'
252                                                 }
253                                             ]
254                                         }
255                                     }
256                                 },
257                                 {
258                                     xtype: 'NumberField',
259                                     xns: Roo.form,
260                                     fieldLabel : 'ID',
261                                     name : 'onid',
262                                     width : 75
263                                 },
264                                 {
265                                     xtype: 'ComboBox',
266                                     xns: Roo.form,
267                                     allowBlank : 'false',
268                                     displayField : 'name',
269                                     editable : 'false',
270                                     emptyText : "Select Person",
271                                     fieldLabel : 'Notify Who',
272                                     forceSelection : true,
273                                     hiddenName : 'person_id',
274                                     listWidth : 500,
275                                     loadingText : "Searching...",
276                                     minChars : 2,
277                                     name : 'person_id_name',
278                                     pageSize : 20,
279                                     qtip : "Select Person",
280                                     queryParam : 'query[name]',
281                                     selectOnFocus : true,
282                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> ({company_id_name}) &lt;{email}&gt;</div>',
283                                     triggerAction : 'all',
284                                     typeAhead : true,
285                                     valueField : 'id',
286                                     width : 300,
287                                     store : {
288                                         xtype: 'Store',
289                                         xns: Roo.data,
290                                         listeners : {
291                                             beforeload : function (_self, o){
292                                                 o.params = o.params || {};
293                                                 // set more here
294                                             }
295                                         },
296                                         remoteSort : true,
297                                         sortInfo : { direction : 'ASC', field: 'name' },
298                                         proxy : {
299                                             xtype: 'HttpProxy',
300                                             xns: Roo.data,
301                                             method : 'GET',
302                                             url : baseURL + '/Roo/core_person'
303                                         },
304                                         reader : {
305                                             xtype: 'JsonReader',
306                                             xns: Roo.data,
307                                             id : 'id',
308                                             root : 'data',
309                                             totalProperty : 'total',
310                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
311                                         }
312                                     }
313                                 },
314                                 {
315                                     xtype: 'ComboBox',
316                                     xns: Roo.form,
317                                     listeners : {
318                                         select : function (combo, record, index)
319                                         {
320                                           _this.grid.footer.onClick('first');
321                                         },
322                                         render : function (_self)
323                                         {
324                                           _this.actionSel = _self;
325                                         }
326                                     },
327                                     allowBlank : true,
328                                     displayField : 'action',
329                                     editable : true,
330                                     fieldLabel : 'Match Event',
331                                     forceSelection : false,
332                                     listWidth : 300,
333                                     loadingText : "Searching...",
334                                     minChars : 2,
335                                     name : 'event',
336                                     pageSize : 20,
337                                     qtip : "Select Action",
338                                     queryParam : 'query[action]',
339                                     selectOnFocus : true,
340                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{action}</b> </div>',
341                                     triggerAction : 'all',
342                                     typeAhead : true,
343                                     valueField : 'action',
344                                     width : 150,
345                                     store : {
346                                         xtype: 'Store',
347                                         xns: Roo.data,
348                                         listeners : {
349                                             beforeload : function (_self, o)
350                                             {
351                                                 o.params = o.params || {};
352                                                 // staff can see all logs, other companies can only see their own.
353                                                 if (typeof(Pman.Login) !='undefined' && Pman.Login.authUser.company_id_comptype != 'OWNER') {
354                                                     o.params.company_id = Pman.Login.authUser.company_id;
355                                                 }
356                                                 o.params._distinct = 'action';
357                                                 o.params._columns ='action';
358                                             }
359                                         },
360                                         remoteSort : true,
361                                         sortInfo : { field : 'action' , direction : 'ASC' },
362                                         proxy : {
363                                             xtype: 'HttpProxy',
364                                             xns: Roo.data,
365                                             method : 'GET',
366                                             url : baseURL + '/Roo/Events.php'
367                                         },
368                                         reader : {
369                                             xtype: 'JsonReader',
370                                             xns: Roo.data,
371                                             totalProperty : 'total',
372                                             root : 'data',
373                                             id : 'id',
374                                             fields : [
375                                                 {
376                                                     'name': 'id',
377                                                     'type': 'int'
378                                                 },
379                                                 {
380                                                     'name': 'person_name',
381                                                     'type': 'string'
382                                                 },
383                                                 {
384                                                     'name': 'event_when',
385                                                     'type': 'date',
386                                                     'dateFormat': 'Y-m-d'
387                                                 },
388                                                 {
389                                                     'name': 'action',
390                                                     'type': 'string'
391                                                 },
392                                                 {
393                                                     'name': 'ipaddr',
394                                                     'type': 'string'
395                                                 },
396                                                 {
397                                                     'name': 'on_id',
398                                                     'type': 'int'
399                                                 },
400                                                 {
401                                                     'name': 'on_table',
402                                                     'type': 'string'
403                                                 },
404                                                 {
405                                                     'name': 'person_id',
406                                                     'type': 'int'
407                                                 },
408                                                 {
409                                                     'name': 'remarks',
410                                                     'type': 'string'
411                                                 },
412                                                 {
413                                                     'name': 'person_id_id',
414                                                     'type': 'int'
415                                                 },
416                                                 {
417                                                     'name': 'person_id_office_id',
418                                                     'type': 'int'
419                                                 },
420                                                 {
421                                                     'name': 'person_id_name',
422                                                     'type': 'string'
423                                                 },
424                                                 {
425                                                     'name': 'person_id_phone',
426                                                     'type': 'string'
427                                                 },
428                                                 {
429                                                     'name': 'person_id_fax',
430                                                     'type': 'string'
431                                                 },
432                                                 {
433                                                     'name': 'person_id_email',
434                                                     'type': 'string'
435                                                 },
436                                                 {
437                                                     'name': 'person_id_company_id',
438                                                     'type': 'int'
439                                                 },
440                                                 {
441                                                     'name': 'person_id_role',
442                                                     'type': 'string'
443                                                 },
444                                                 {
445                                                     'name': 'person_id_active',
446                                                     'type': 'int'
447                                                 },
448                                                 {
449                                                     'name': 'person_id_remarks',
450                                                     'type': 'string'
451                                                 },
452                                                 {
453                                                     'name': 'person_id_passwd',
454                                                     'type': 'string'
455                                                 },
456                                                 {
457                                                     'name': 'person_id_owner_id',
458                                                     'type': 'int'
459                                                 },
460                                                 {
461                                                     'name': 'person_id_lang',
462                                                     'type': 'string'
463                                                 },
464                                                 {
465                                                     'name': 'person_id_no_reset_sent',
466                                                     'type': 'int'
467                                                 },
468                                                 {
469                                                     'name': 'person_id_action_type',
470                                                     'type': 'string'
471                                                 },
472                                                 {
473                                                     'name': 'person_id_project_id',
474                                                     'type': 'int'
475                                                 },
476                                                 {
477                                                     'name': 'person_id_deleted_by',
478                                                     'type': 'int'
479                                                 },
480                                                 {
481                                                     'name': 'person_id_deleted_dt',
482                                                     'type': 'date'
483                                                 }
484                                             ]
485                                         }
486                                     }
487                                 },
488                                 {
489                                     xtype: 'ComboBox',
490                                     xns: Roo.form,
491                                     allowBlank : true,
492                                     displayField : 'val',
493                                     editable : true,
494                                     fieldLabel : 'Action',
495                                     forceSelection : false,
496                                     listWidth : 200,
497                                     name : 'medium',
498                                     triggerAction : 'all',
499                                     valueField : 'val',
500                                     width : 200,
501                                     store : {
502                                         xtype: 'SimpleStore',
503                                         xns: Roo.data,
504                                         data : [ [ 'email' ], [ 'APPROVAL' ], ['ENDOFDAYMAIL'] ],
505                                         fields : [ 'val' ]
506                                     }
507                                 },
508                                 {
509                                     xtype: 'Checkbox',
510                                     xns: Roo.form,
511                                     fieldLabel : 'Active?',
512                                     name : 'active'
513                                 },
514                                 {
515                                     xtype: 'Hidden',
516                                     xns: Roo.form,
517                                     name : 'id'
518                                 }
519                             ]
520                         }
521                     ]
522                 }
523             ],
524             center : {
525                 xtype: 'LayoutRegion',
526                 xns: Roo
527             },
528             buttons : [
529                 {
530                     xtype: 'Button',
531                     xns: Roo,
532                     listeners : {
533                         click : function (_self, e)
534                         {
535                             _this.dialog.hide();
536                         }
537                     },
538                     text : "Cancel"
539                 },
540                 {
541                     xtype: 'Button',
542                     xns: Roo,
543                     listeners : {
544                         click : function (_self, e)
545                         {
546                             // do some checks?
547                              
548                             
549                          
550                             _this.form.doAction("submit");
551                         
552                         }
553                     },
554                     text : "Save"
555                 }
556             ]
557         });
558     }
559 };