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: 'TextField',
258                                     xns: Roo.form,
259                                     fieldLabel : 'Onid',
260                                     name : 'onid',
261                                     width : 75
262                                 },
263                                 {
264                                     xtype: 'ComboBox',
265                                     xns: Roo.form,
266                                     allowBlank : 'false',
267                                     editable : 'false',
268                                     emptyText : "Select Person",
269                                     forceSelection : true,
270                                     listWidth : 400,
271                                     loadingText : "Searching...",
272                                     minChars : 2,
273                                     pageSize : 20,
274                                     qtip : "Select Person",
275                                     selectOnFocus : true,
276                                     triggerAction : 'all',
277                                     typeAhead : true,
278                                     width : 300,
279                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
280                                     queryParam : 'query[name]',
281                                     fieldLabel : 'Person',
282                                     valueField : 'id',
283                                     displayField : 'name',
284                                     hiddenName : 'person_id',
285                                     name : 'person_id_name',
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: 'TextField',
322                                     xns: Roo.form,
323                                     fieldLabel : 'Action',
324                                     name : 'medium',
325                                     width : 200
326                                 },
327                                 {
328                                     xtype: 'TextField',
329                                     xns: Roo.form,
330                                     fieldLabel : 'Active',
331                                     name : 'active',
332                                     width : 75
333                                 },
334                                 {
335                                     xtype: 'Hidden',
336                                     xns: Roo.form,
337                                     name : 'id'
338                                 }
339                             ]
340                         }
341                     ]
342                 }
343             ],
344             center : {
345                 xtype: 'LayoutRegion',
346                 xns: Roo
347             },
348             buttons : [
349                 {
350                     xtype: 'Button',
351                     xns: Roo,
352                     listeners : {
353                         click : function (_self, e)
354                         {
355                             _this.dialog.hide();
356                         }
357                     },
358                     text : "Cancel"
359                 },
360                 {
361                     xtype: 'Button',
362                     xns: Roo,
363                     listeners : {
364                         click : function (_self, e)
365                         {
366                             // do some checks?
367                              
368                             
369                             _this.dialog.el.mask("Saving");
370                             _this.form.doAction("submit");
371                         
372                         }
373                     },
374                     text : "Save"
375                 }
376             ]
377         });
378     }
379 };