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: 'ComboBox',
315                                     xns: Roo.form,
316                                     listeners : {
317                                         select : function (combo, record, index)
318                                         {
319                                           _this.grid.footer.onClick('first');
320                                         },
321                                         render : function (_self)
322                                         {
323                                           _this.actionSel = _self;
324                                         }
325                                     },
326                                     allowBlank : true,
327                                     displayField : 'action',
328                                     editable : true,
329                                     emptyText : "Select Action",
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 (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 : false,
492                                     alwaysQuery : true,
493                                     displayField : 'title',
494                                     editable : false,
495                                     fieldLabel : 'Country',
496                                     hiddenName : 'country',
497                                     listWidth : 200,
498                                     name : 'country_name',
499                                     triggerAction : 'all',
500                                     valueField : 'code',
501                                     width : 200,
502                                     store : {
503                                         xtype: 'SimpleStore',
504                                         xns: Roo.data,
505                                         fields : [ 'val' ]
506                                     }
507                                 },
508                                 {
509                                     xtype: 'TextField',
510                                     xns: Roo.form,
511                                     fieldLabel : 'Action',
512                                     name : 'medium',
513                                     width : 200
514                                 },
515                                 {
516                                     xtype: 'Checkbox',
517                                     xns: Roo.form,
518                                     fieldLabel : 'Active?',
519                                     name : 'active'
520                                 },
521                                 {
522                                     xtype: 'Hidden',
523                                     xns: Roo.form,
524                                     name : 'id'
525                                 }
526                             ]
527                         }
528                     ]
529                 }
530             ],
531             center : {
532                 xtype: 'LayoutRegion',
533                 xns: Roo
534             },
535             buttons : [
536                 {
537                     xtype: 'Button',
538                     xns: Roo,
539                     listeners : {
540                         click : function (_self, e)
541                         {
542                             _this.dialog.hide();
543                         }
544                     },
545                     text : "Cancel"
546                 },
547                 {
548                     xtype: 'Button',
549                     xns: Roo,
550                     listeners : {
551                         click : function (_self, e)
552                         {
553                             // do some checks?
554                              
555                             
556                             _this.dialog.el.mask("Saving");
557                             _this.form.doAction("submit");
558                         
559                         }
560                     },
561                     text : "Save"
562                 }
563             ]
564         });
565     }
566 };