Pman.Tab.AdminWatches.bjs
[Pman.Admin] / Pman.Tab.AdminWatches.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         modKey : '860-Pman.Tab.AdminWatches',
12         module : Pman.Tab.AdminWatches,
13         region : 'center',
14         parent : Pman.Tab.Admin,
15         name : "Pman.Tab.AdminWatches",
16         disabled : false, 
17         permname: '' 
18     });
19 });
20
21 Pman.Tab.AdminWatches = new Roo.util.Observable({
22
23     panel : false,
24     disabled : false,
25     parentLayout:  false,
26
27     add : function(parentLayout, region)
28     {
29
30         var _this = this;
31         this.parentLayout = parentLayout;
32
33         this.panel = parentLayout.addxtype({
34             xtype: 'GridPanel',
35             xns: Roo,
36             listeners : {
37                 activate : function() {
38                     _this.panel = this;
39                     if (_this.grid) {
40                         _this.grid.footer.onClick('first');
41                     }
42                 }
43             },
44             background : true,
45             fitContainer : true,
46             fitToframe : true,
47             region : 'center',
48             tableName : 'core_watch',
49             title : "Watches",
50             grid : {
51                 xtype: 'Grid',
52                 xns: Roo.grid,
53                 listeners : {
54                     render : function() 
55                     {
56                         _this.grid = this; 
57                         //_this.dialog = Pman.Dialog.FILL_IN
58                         if (_this.panel.active) {
59                            this.footer.onClick('first');
60                         }
61                     },
62                     rowdblclick : function (_self, rowIndex, e)
63                     {
64                         if (!_this.dialog) return;
65                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
66                             _this.grid.footer.onClick('first');
67                         }); 
68                     }
69                 },
70                 autoExpandColumn : 'person_id_name',
71                 loadMask : true,
72                 dataSource : {
73                     xtype: 'Store',
74                     xns: Roo.data,
75                     remoteSort : true,
76                     sortInfo : { field : 'ontable', direction: 'ASC' },
77                     proxy : {
78                         xtype: 'HttpProxy',
79                         xns: Roo.data,
80                         method : 'GET',
81                         url : baseURL + '/Roo/core_watch.php'
82                     },
83                     reader : {
84                         xtype: 'JsonReader',
85                         xns: Roo.data,
86                         totalProperty : 'total',
87                         root : 'data',
88                         id : 'id',
89                         fields : [
90                             {
91                                 'name': 'id',
92                                 'type': 'int'
93                             },
94                             {
95                                 'name': 'ontable',
96                                 'type': 'string'
97                             },
98                             {
99                                 'name': 'onid',
100                                 'type': 'int'
101                             },
102                             {
103                                 'name': 'person_id',
104                                 'type': 'int'
105                             },
106                             {
107                                 'name': 'event',
108                                 'type': 'string'
109                             },
110                             {
111                                 'name': 'medium',
112                                 'type': 'string'
113                             },
114                             {
115                                 'name': 'active',
116                                 'type': 'int'
117                             },
118                             {
119                                 'name': 'person_id_id',
120                                 'type': 'int'
121                             },
122                             {
123                                 'name': 'person_id_office_id',
124                                 'type': 'int'
125                             },
126                             {
127                                 'name': 'person_id_name',
128                                 'type': 'string'
129                             },
130                             {
131                                 'name': 'person_id_phone',
132                                 'type': 'string'
133                             },
134                             {
135                                 'name': 'person_id_fax',
136                                 'type': 'string'
137                             },
138                             {
139                                 'name': 'person_id_email',
140                                 'type': 'string'
141                             },
142                             {
143                                 'name': 'person_id_company_id',
144                                 'type': 'int'
145                             },
146                             {
147                                 'name': 'person_id_role',
148                                 'type': 'string'
149                             },
150                             {
151                                 'name': 'person_id_active',
152                                 'type': 'int'
153                             },
154                             {
155                                 'name': 'person_id_remarks',
156                                 'type': 'string'
157                             },
158                             {
159                                 'name': 'person_id_passwd',
160                                 'type': 'string'
161                             },
162                             {
163                                 'name': 'person_id_owner_id',
164                                 'type': 'int'
165                             },
166                             {
167                                 'name': 'person_id_lang',
168                                 'type': 'string'
169                             },
170                             {
171                                 'name': 'person_id_no_reset_sent',
172                                 'type': 'int'
173                             },
174                             {
175                                 'name': 'person_id_action_type',
176                                 'type': 'string'
177                             },
178                             {
179                                 'name': 'person_id_project_id',
180                                 'type': 'int'
181                             },
182                             {
183                                 'name': 'person_id_deleted_by',
184                                 'type': 'int'
185                             },
186                             {
187                                 'name': 'person_id_deleted_dt',
188                                 'type': 'date'
189                             }
190                         ]
191                     }
192                 },
193                 footer : {
194                     xtype: 'PagingToolbar',
195                     xns: Roo,
196                     pageSize : 25,
197                     displayInfo : true,
198                     displayMsg : "Displaying core_watch{0} - {1} of {2}",
199                     emptyMsg : "No core_watch found"
200                 },
201                 toolbar : {
202                     xtype: 'Toolbar',
203                     xns: Roo,
204                     items : [
205                         {
206                             xtype: 'Button',
207                             xns: Roo.Toolbar,
208                             text : "Add",
209                             cls : 'x-btn-text-icon',
210                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
211                             listeners : {
212                                 click : function()
213                                 {
214                                     if (!_this.dialog) return;
215                                     _this.dialog.show( { id : 0 } , function() {
216                                         _this.grid.footer.onClick('first');
217                                    }); 
218                                 }
219                             }
220                         },
221                         {
222                             xtype: 'Button',
223                             xns: Roo.Toolbar,
224                             text : "Edit",
225                             cls : 'x-btn-text-icon',
226                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
227                             listeners : {
228                                 click : function()
229                                 {
230                                     var s = _this.grid.getSelectionModel().getSelections();
231                                     if (!s.length || (s.length > 1))  {
232                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
233                                         return;
234                                     }
235                                     if (!_this.dialog) return;
236                                     _this.dialog.show(s[0].data, function() {
237                                         _this.grid.footer.onClick('first');
238                                     }); 
239                                     
240                                 }
241                             }
242                         },
243                         {
244                             xtype: 'Button',
245                             xns: Roo.Toolbar,
246                             text : "Delete",
247                             cls : 'x-btn-text-icon',
248                             icon : rootURL + '/Pman/templates/images/trash.gif',
249                             listeners : {
250                                 click : function()
251                                 {
252                                      Pman.genericDelete(_this, 'core_watch'); 
253                                 }
254                             }
255                         },
256                         {
257                             xtype: 'TextItem',
258                             xns: Roo.Toolbar,
259                             text : "Show"
260                         },
261                         {
262                             xtype: 'ComboBox',
263                             xns: Roo.form,
264                             listeners : {
265                                 select : function (combo, record, index)
266                                 {
267                                   _this.grid.footer.onClick('first');
268                                 },
269                                 render : function (_self)
270                                 {
271                                   _this.affectSel = _self;
272                                 }
273                             },
274                             allowBlank : true,
275                             displayField : 'on_table',
276                             editable : false,
277                             emptyText : "Select Affects",
278                             forceSelection : true,
279                             listWidth : 300,
280                             loadingText : "Searching...",
281                             minChars : 2,
282                             name : 'on_table',
283                             pageSize : 20,
284                             qtip : "Select Action",
285                             queryParam : 'query[on_table]',
286                             selectOnFocus : true,
287                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{on_table}</b> </div>',
288                             triggerAction : 'all',
289                             typeAhead : true,
290                             valueField : 'action',
291                             width : 150,
292                             store : {
293                                 xtype: 'Store',
294                                 xns: Roo.data,
295                                 listeners : {
296                                     beforeload : function (_self, o)
297                                     {
298                                         o.params = o.params || {};
299                                         // staff can see all logs, other companies can only see their own.
300                                         if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
301                                             o.params.company_id = Pman.Login.authUser.company_id;
302                                         }
303                                         o.params._distinct = 'on_table';
304                                         o.params._columns ='on_table';
305                                     }
306                                 },
307                                 remoteSort : true,
308                                 sortInfo : { field : 'on_table' , direction : 'ASC' },
309                                 proxy : {
310                                     xtype: 'HttpProxy',
311                                     xns: Roo.data,
312                                     method : 'GET',
313                                     url : baseURL + '/Roo/Core_watch.php'
314                                 },
315                                 reader : {
316                                     xtype: 'JsonReader',
317                                     xns: Roo.data,
318                                     totalProperty : 'total',
319                                     root : 'data',
320                                     id : 'id',
321                                     fields : [
322                                         {
323                                             'name': 'id',
324                                             'type': 'int'
325                                         },
326                                         {
327                                             'name': 'person_name',
328                                             'type': 'string'
329                                         },
330                                         {
331                                             'name': 'event_when',
332                                             'type': 'date',
333                                             'dateFormat': 'Y-m-d'
334                                         },
335                                         {
336                                             'name': 'action',
337                                             'type': 'string'
338                                         },
339                                         {
340                                             'name': 'ipaddr',
341                                             'type': 'string'
342                                         },
343                                         {
344                                             'name': 'on_id',
345                                             'type': 'int'
346                                         },
347                                         {
348                                             'name': 'on_table',
349                                             'type': 'string'
350                                         },
351                                         {
352                                             'name': 'person_id',
353                                             'type': 'int'
354                                         },
355                                         {
356                                             'name': 'remarks',
357                                             'type': 'string'
358                                         },
359                                         {
360                                             'name': 'person_id_id',
361                                             'type': 'int'
362                                         },
363                                         {
364                                             'name': 'person_id_office_id',
365                                             'type': 'int'
366                                         },
367                                         {
368                                             'name': 'person_id_name',
369                                             'type': 'string'
370                                         },
371                                         {
372                                             'name': 'person_id_phone',
373                                             'type': 'string'
374                                         },
375                                         {
376                                             'name': 'person_id_fax',
377                                             'type': 'string'
378                                         },
379                                         {
380                                             'name': 'person_id_email',
381                                             'type': 'string'
382                                         },
383                                         {
384                                             'name': 'person_id_company_id',
385                                             'type': 'int'
386                                         },
387                                         {
388                                             'name': 'person_id_role',
389                                             'type': 'string'
390                                         },
391                                         {
392                                             'name': 'person_id_active',
393                                             'type': 'int'
394                                         },
395                                         {
396                                             'name': 'person_id_remarks',
397                                             'type': 'string'
398                                         },
399                                         {
400                                             'name': 'person_id_passwd',
401                                             'type': 'string'
402                                         },
403                                         {
404                                             'name': 'person_id_owner_id',
405                                             'type': 'int'
406                                         },
407                                         {
408                                             'name': 'person_id_lang',
409                                             'type': 'string'
410                                         },
411                                         {
412                                             'name': 'person_id_no_reset_sent',
413                                             'type': 'int'
414                                         },
415                                         {
416                                             'name': 'person_id_action_type',
417                                             'type': 'string'
418                                         },
419                                         {
420                                             'name': 'person_id_project_id',
421                                             'type': 'int'
422                                         },
423                                         {
424                                             'name': 'person_id_deleted_by',
425                                             'type': 'int'
426                                         },
427                                         {
428                                             'name': 'person_id_deleted_dt',
429                                             'type': 'date'
430                                         }
431                                     ]
432                                 }
433                             }
434                         },
435                         {
436                             xtype: 'Fill',
437                             xns: Roo.Toolbar
438                         },
439                         {
440                             xtype: 'Button',
441                             xns: Roo.Toolbar,
442                             text : "Add",
443                             cls : 'x-btn-text-icon',
444                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
445                             listeners : {
446                                 click : function()
447                                 {
448                                     if (!_this.dialog) return;
449                                     _this.dialog.show( { id : 0 } , function() {
450                                         _this.grid.footer.onClick('first');
451                                    }); 
452                                 }
453                             }
454                         },
455                         {
456                             xtype: 'Button',
457                             xns: Roo.Toolbar,
458                             text : "Edit",
459                             cls : 'x-btn-text-icon',
460                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
461                             listeners : {
462                                 click : function()
463                                 {
464                                     var s = _this.grid.getSelectionModel().getSelections();
465                                     if (!s.length || (s.length > 1))  {
466                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
467                                         return;
468                                     }
469                                     if (!_this.dialog) return;
470                                     _this.dialog.show(s[0].data, function() {
471                                         _this.grid.footer.onClick('first');
472                                     }); 
473                                     
474                                 }
475                             }
476                         },
477                         {
478                             xtype: 'Button',
479                             xns: Roo.Toolbar,
480                             text : "Delete",
481                             cls : 'x-btn-text-icon',
482                             icon : rootURL + '/Pman/templates/images/trash.gif',
483                             listeners : {
484                                 click : function()
485                                 {
486                                      Pman.genericDelete(_this, 'core_watch'); 
487                                 }
488                             }
489                         }
490                     ]
491                 },
492                 colModel : [
493                     {
494                         xtype: 'ColumnModel',
495                         xns: Roo.grid,
496                         dataIndex : 'event',
497                         header : 'Watch Event',
498                         width : 100,
499                         renderer : function(v) { return String.format('{0}', v); }
500                     },
501                     {
502                         xtype: 'ColumnModel',
503                         xns: Roo.grid,
504                         dataIndex : 'ontable',
505                         header : 'Watch Table',
506                         width : 150,
507                         renderer : function(v) { return String.format('{0}', v); }
508                     },
509                     {
510                         xtype: 'ColumnModel',
511                         xns: Roo.grid,
512                         dataIndex : 'onid',
513                         header : 'Watch ID',
514                         width : 75,
515                         renderer : function(v) { return String.format('{0}', v); }
516                     },
517                     {
518                         xtype: 'ColumnModel',
519                         xns: Roo.grid,
520                         dataIndex : 'person_id_name',
521                         header : 'Who get\'s notified',
522                         width : 150,
523                         renderer : function(v) { return String.format('{0}', v); }
524                     },
525                     {
526                         xtype: 'ColumnModel',
527                         xns: Roo.grid,
528                         dataIndex : 'medium',
529                         header : 'What happens',
530                         width : 200,
531                         renderer : function(v) { return String.format('{0}', v); }
532                     },
533                     {
534                         xtype: 'ColumnModel',
535                         xns: Roo.grid,
536                         header : 'Active',
537                         width : 75,
538                         dataIndex : 'active',
539                         renderer : function(v) { return String.format('{0}', v); }
540                     }
541                 ]
542             }
543         });
544         this.layout = this.panel.layout;
545
546     }
547 });