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