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 : "Delete",
209                             cls : 'x-btn-text-icon',
210                             icon : rootURL + '/Pman/templates/images/trash.gif',
211                             listeners : {
212                                 click : function()
213                                 {
214                                      Pman.genericDelete(_this, 'core_watch'); 
215                                 }
216                             }
217                         },
218                         {
219                             xtype: 'TextItem',
220                             xns: Roo.Toolbar,
221                             text : "Show"
222                         },
223                         {
224                             xtype: 'ComboBox',
225                             xns: Roo.form,
226                             listeners : {
227                                 select : function (combo, record, index)
228                                 {
229                                   _this.grid.footer.onClick('first');
230                                 },
231                                 render : function (_self)
232                                 {
233                                   _this.affectSel = _self;
234                                 }
235                             },
236                             allowBlank : true,
237                             displayField : 'on_table',
238                             editable : false,
239                             emptyText : "Select Affects",
240                             forceSelection : true,
241                             listWidth : 300,
242                             loadingText : "Searching...",
243                             minChars : 2,
244                             name : 'on_table',
245                             pageSize : 20,
246                             qtip : "Select Action",
247                             queryParam : 'query[on_table]',
248                             selectOnFocus : true,
249                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{on_table}</b> </div>',
250                             triggerAction : 'all',
251                             typeAhead : true,
252                             valueField : 'action',
253                             width : 150,
254                             store : {
255                                 xtype: 'Store',
256                                 xns: Roo.data,
257                                 listeners : {
258                                     beforeload : function (_self, o)
259                                     {
260                                         o.params = o.params || {};
261                                         // staff can see all logs, other companies can only see their own.
262                                         if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
263                                             o.params.company_id = Pman.Login.authUser.company_id;
264                                         }
265                                         o.params._distinct = 'on_table';
266                                         o.params._columns ='on_table';
267                                     }
268                                 },
269                                 remoteSort : true,
270                                 sortInfo : { field : 'on_table' , direction : 'ASC' },
271                                 proxy : {
272                                     xtype: 'HttpProxy',
273                                     xns: Roo.data,
274                                     method : 'GET',
275                                     url : baseURL + '/Roo/Core_watch.php'
276                                 },
277                                 reader : {
278                                     xtype: 'JsonReader',
279                                     xns: Roo.data,
280                                     totalProperty : 'total',
281                                     root : 'data',
282                                     id : 'id',
283                                     fields : [
284                                         {
285                                             'name': 'id',
286                                             'type': 'int'
287                                         },
288                                         {
289                                             'name': 'person_name',
290                                             'type': 'string'
291                                         },
292                                         {
293                                             'name': 'event_when',
294                                             'type': 'date',
295                                             'dateFormat': 'Y-m-d'
296                                         },
297                                         {
298                                             'name': 'action',
299                                             'type': 'string'
300                                         },
301                                         {
302                                             'name': 'ipaddr',
303                                             'type': 'string'
304                                         },
305                                         {
306                                             'name': 'on_id',
307                                             'type': 'int'
308                                         },
309                                         {
310                                             'name': 'on_table',
311                                             'type': 'string'
312                                         },
313                                         {
314                                             'name': 'person_id',
315                                             'type': 'int'
316                                         },
317                                         {
318                                             'name': 'remarks',
319                                             'type': 'string'
320                                         },
321                                         {
322                                             'name': 'person_id_id',
323                                             'type': 'int'
324                                         },
325                                         {
326                                             'name': 'person_id_office_id',
327                                             'type': 'int'
328                                         },
329                                         {
330                                             'name': 'person_id_name',
331                                             'type': 'string'
332                                         },
333                                         {
334                                             'name': 'person_id_phone',
335                                             'type': 'string'
336                                         },
337                                         {
338                                             'name': 'person_id_fax',
339                                             'type': 'string'
340                                         },
341                                         {
342                                             'name': 'person_id_email',
343                                             'type': 'string'
344                                         },
345                                         {
346                                             'name': 'person_id_company_id',
347                                             'type': 'int'
348                                         },
349                                         {
350                                             'name': 'person_id_role',
351                                             'type': 'string'
352                                         },
353                                         {
354                                             'name': 'person_id_active',
355                                             'type': 'int'
356                                         },
357                                         {
358                                             'name': 'person_id_remarks',
359                                             'type': 'string'
360                                         },
361                                         {
362                                             'name': 'person_id_passwd',
363                                             'type': 'string'
364                                         },
365                                         {
366                                             'name': 'person_id_owner_id',
367                                             'type': 'int'
368                                         },
369                                         {
370                                             'name': 'person_id_lang',
371                                             'type': 'string'
372                                         },
373                                         {
374                                             'name': 'person_id_no_reset_sent',
375                                             'type': 'int'
376                                         },
377                                         {
378                                             'name': 'person_id_action_type',
379                                             'type': 'string'
380                                         },
381                                         {
382                                             'name': 'person_id_project_id',
383                                             'type': 'int'
384                                         },
385                                         {
386                                             'name': 'person_id_deleted_by',
387                                             'type': 'int'
388                                         },
389                                         {
390                                             'name': 'person_id_deleted_dt',
391                                             'type': 'date'
392                                         }
393                                     ]
394                                 }
395                             }
396                         },
397                         {
398                             xtype: 'Fill',
399                             xns: Roo.Toolbar
400                         },
401                         {
402                             xtype: 'Button',
403                             xns: Roo.Toolbar,
404                             text : "Add",
405                             cls : 'x-btn-text-icon',
406                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
407                             listeners : {
408                                 click : function()
409                                 {
410                                     if (!_this.dialog) return;
411                                     _this.dialog.show( { id : 0 } , function() {
412                                         _this.grid.footer.onClick('first');
413                                    }); 
414                                 }
415                             }
416                         },
417                         {
418                             xtype: 'Button',
419                             xns: Roo.Toolbar,
420                             text : "Edit",
421                             cls : 'x-btn-text-icon',
422                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
423                             listeners : {
424                                 click : function()
425                                 {
426                                     var s = _this.grid.getSelectionModel().getSelections();
427                                     if (!s.length || (s.length > 1))  {
428                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
429                                         return;
430                                     }
431                                     if (!_this.dialog) return;
432                                     _this.dialog.show(s[0].data, function() {
433                                         _this.grid.footer.onClick('first');
434                                     }); 
435                                     
436                                 }
437                             }
438                         },
439                         {
440                             xtype: 'Button',
441                             xns: Roo.Toolbar,
442                             text : "Delete",
443                             cls : 'x-btn-text-icon',
444                             icon : rootURL + '/Pman/templates/images/trash.gif',
445                             listeners : {
446                                 click : function()
447                                 {
448                                      Pman.genericDelete(_this, 'core_watch'); 
449                                 }
450                             }
451                         }
452                     ]
453                 },
454                 colModel : [
455                     {
456                         xtype: 'ColumnModel',
457                         xns: Roo.grid,
458                         dataIndex : 'event',
459                         header : 'Watch Event',
460                         width : 100,
461                         renderer : function(v) { return String.format('{0}', v); }
462                     },
463                     {
464                         xtype: 'ColumnModel',
465                         xns: Roo.grid,
466                         dataIndex : 'ontable',
467                         header : 'Watch Table',
468                         width : 150,
469                         renderer : function(v) { return String.format('{0}', v); }
470                     },
471                     {
472                         xtype: 'ColumnModel',
473                         xns: Roo.grid,
474                         dataIndex : 'onid',
475                         header : 'Watch ID',
476                         width : 75,
477                         renderer : function(v) { return String.format('{0}', v); }
478                     },
479                     {
480                         xtype: 'ColumnModel',
481                         xns: Roo.grid,
482                         dataIndex : 'person_id_name',
483                         header : 'Who get\'s notified',
484                         width : 150,
485                         renderer : function(v) { return String.format('{0}', v); }
486                     },
487                     {
488                         xtype: 'ColumnModel',
489                         xns: Roo.grid,
490                         dataIndex : 'medium',
491                         header : 'What happens',
492                         width : 200,
493                         renderer : function(v) { return String.format('{0}', v); }
494                     },
495                     {
496                         xtype: 'ColumnModel',
497                         xns: Roo.grid,
498                         header : 'Active',
499                         width : 75,
500                         dataIndex : 'active',
501                         renderer : function(v) { return String.format('{0}', v); }
502                     }
503                 ]
504             }
505         });
506         this.layout = this.panel.layout;
507
508     }
509 });