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                                     forceSelection : true,
338                                     listWidth : 300,
339                                     loadingText : "Searching...",
340                                     minChars : 2,
341                                     name : 'action',
342                                     pageSize : 20,
343                                     qtip : "Select Action",
344                                     queryParam : 'query[action]',
345                                     selectOnFocus : true,
346                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{action}</b> </div>',
347                                     triggerAction : 'all',
348                                     typeAhead : true,
349                                     valueField : 'action',
350                                     width : 150,
351                                     store : {
352                                         xtype: 'Store',
353                                         xns: Roo.data,
354                                         listeners : {
355                                             beforeload : function (_self, o)
356                                             {
357                                                 o.params = o.params || {};
358                                                 // staff can see all logs, other companies can only see their own.
359                                                 if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
360                                                     o.params.company_id = Pman.Login.authUser.company_id;
361                                                 }
362                                                 o.params._distinct = 'action';
363                                                 o.params._columns ='action';
364                                             }
365                                         },
366                                         remoteSort : true,
367                                         sortInfo : { field : 'action' , direction : 'ASC' },
368                                         proxy : {
369                                             xtype: 'HttpProxy',
370                                             xns: Roo.data,
371                                             method : 'GET',
372                                             url : baseURL + '/Roo/Events.php'
373                                         },
374                                         reader : {
375                                             xtype: 'JsonReader',
376                                             xns: Roo.data,
377                                             totalProperty : 'total',
378                                             root : 'data',
379                                             id : 'id',
380                                             fields : [
381                                                 {
382                                                     'name': 'id',
383                                                     'type': 'int'
384                                                 },
385                                                 {
386                                                     'name': 'person_name',
387                                                     'type': 'string'
388                                                 },
389                                                 {
390                                                     'name': 'event_when',
391                                                     'type': 'date',
392                                                     'dateFormat': 'Y-m-d'
393                                                 },
394                                                 {
395                                                     'name': 'action',
396                                                     'type': 'string'
397                                                 },
398                                                 {
399                                                     'name': 'ipaddr',
400                                                     'type': 'string'
401                                                 },
402                                                 {
403                                                     'name': 'on_id',
404                                                     'type': 'int'
405                                                 },
406                                                 {
407                                                     'name': 'on_table',
408                                                     'type': 'string'
409                                                 },
410                                                 {
411                                                     'name': 'person_id',
412                                                     'type': 'int'
413                                                 },
414                                                 {
415                                                     'name': 'remarks',
416                                                     'type': 'string'
417                                                 },
418                                                 {
419                                                     'name': 'person_id_id',
420                                                     'type': 'int'
421                                                 },
422                                                 {
423                                                     'name': 'person_id_office_id',
424                                                     'type': 'int'
425                                                 },
426                                                 {
427                                                     'name': 'person_id_name',
428                                                     'type': 'string'
429                                                 },
430                                                 {
431                                                     'name': 'person_id_phone',
432                                                     'type': 'string'
433                                                 },
434                                                 {
435                                                     'name': 'person_id_fax',
436                                                     'type': 'string'
437                                                 },
438                                                 {
439                                                     'name': 'person_id_email',
440                                                     'type': 'string'
441                                                 },
442                                                 {
443                                                     'name': 'person_id_company_id',
444                                                     'type': 'int'
445                                                 },
446                                                 {
447                                                     'name': 'person_id_role',
448                                                     'type': 'string'
449                                                 },
450                                                 {
451                                                     'name': 'person_id_active',
452                                                     'type': 'int'
453                                                 },
454                                                 {
455                                                     'name': 'person_id_remarks',
456                                                     'type': 'string'
457                                                 },
458                                                 {
459                                                     'name': 'person_id_passwd',
460                                                     'type': 'string'
461                                                 },
462                                                 {
463                                                     'name': 'person_id_owner_id',
464                                                     'type': 'int'
465                                                 },
466                                                 {
467                                                     'name': 'person_id_lang',
468                                                     'type': 'string'
469                                                 },
470                                                 {
471                                                     'name': 'person_id_no_reset_sent',
472                                                     'type': 'int'
473                                                 },
474                                                 {
475                                                     'name': 'person_id_action_type',
476                                                     'type': 'string'
477                                                 },
478                                                 {
479                                                     'name': 'person_id_project_id',
480                                                     'type': 'int'
481                                                 },
482                                                 {
483                                                     'name': 'person_id_deleted_by',
484                                                     'type': 'int'
485                                                 },
486                                                 {
487                                                     'name': 'person_id_deleted_dt',
488                                                     'type': 'date'
489                                                 }
490                                             ]
491                                         }
492                                     }
493                                 },
494                                 {
495                                     xtype: 'TextField',
496                                     xns: Roo.form,
497                                     fieldLabel : 'Action',
498                                     name : 'medium',
499                                     width : 200
500                                 },
501                                 {
502                                     xtype: 'TextField',
503                                     xns: Roo.form,
504                                     fieldLabel : 'Active',
505                                     name : 'active',
506                                     width : 75
507                                 },
508                                 {
509                                     xtype: 'Hidden',
510                                     xns: Roo.form,
511                                     name : 'id'
512                                 }
513                             ]
514                         }
515                     ]
516                 }
517             ],
518             center : {
519                 xtype: 'LayoutRegion',
520                 xns: Roo
521             },
522             buttons : [
523                 {
524                     xtype: 'Button',
525                     xns: Roo,
526                     listeners : {
527                         click : function (_self, e)
528                         {
529                             _this.dialog.hide();
530                         }
531                     },
532                     text : "Cancel"
533                 },
534                 {
535                     xtype: 'Button',
536                     xns: Roo,
537                     listeners : {
538                         click : function (_self, e)
539                         {
540                             // do some checks?
541                              
542                             
543                             _this.dialog.el.mask("Saving");
544                             _this.form.doAction("submit");
545                         
546                         }
547                     },
548                     text : "Save"
549                 }
550             ]
551         });
552     }
553 };