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