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 : 400,
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: 'TextField',
83                                     xns: Roo.form,
84                                     fieldLabel : 'Ontable',
85                                     name : 'ontable',
86                                     width : 200
87                                 },
88                                 {
89                                     xtype: 'ComboBox',
90                                     xns: Roo.form,
91                                     listeners : {
92                                         select : function (combo, record, index)
93                                         {
94                                           _this.grid.footer.onClick('first');
95                                         },
96                                         render : function (_self)
97                                         {
98                                           _this.affectSel = _self;
99                                         }
100                                     },
101                                     allowBlank : true,
102                                     displayField : 'on_table',
103                                     editable : false,
104                                     emptyText : "Select Table",
105                                     fieldLabel : 'Table',
106                                     forceSelection : true,
107                                     listWidth : 300,
108                                     loadingText : "Searching...",
109                                     minChars : 2,
110                                     name : 'ontable',
111                                     pageSize : 20,
112                                     qtip : "Select Action",
113                                     queryParam : 'query[on_table]',
114                                     selectOnFocus : true,
115                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{on_table}</b> </div>',
116                                     triggerAction : 'all',
117                                     typeAhead : true,
118                                     valueField : 'action',
119                                     width : 150,
120                                     store : {
121                                         xtype: 'Store',
122                                         xns: Roo.data,
123                                         listeners : {
124                                             beforeload : function (_self, o)
125                                             {
126                                                 o.params = o.params || {};
127                                                 // staff can see all logs, other companies can only see their own.
128                                                 if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
129                                                     o.params.company_id = Pman.Login.authUser.company_id;
130                                                 }
131                                                 o.params._distinct = 'on_table';
132                                                 o.params._columns ='on_table';
133                                             }
134                                         },
135                                         remoteSort : true,
136                                         sortInfo : { field : 'on_table' , direction : 'ASC' },
137                                         proxy : {
138                                             xtype: 'HttpProxy',
139                                             xns: Roo.data,
140                                             method : 'GET',
141                                             url : baseURL + '/Roo/Events.php'
142                                         },
143                                         reader : {
144                                             xtype: 'JsonReader',
145                                             xns: Roo.data,
146                                             totalProperty : 'total',
147                                             root : 'data',
148                                             id : 'id',
149                                             fields : [
150                                                 {
151                                                     'name': 'id',
152                                                     'type': 'int'
153                                                 },
154                                                 {
155                                                     'name': 'person_name',
156                                                     'type': 'string'
157                                                 },
158                                                 {
159                                                     'name': 'event_when',
160                                                     'type': 'date',
161                                                     'dateFormat': 'Y-m-d'
162                                                 },
163                                                 {
164                                                     'name': 'action',
165                                                     'type': 'string'
166                                                 },
167                                                 {
168                                                     'name': 'ipaddr',
169                                                     'type': 'string'
170                                                 },
171                                                 {
172                                                     'name': 'on_id',
173                                                     'type': 'int'
174                                                 },
175                                                 {
176                                                     'name': 'on_table',
177                                                     'type': 'string'
178                                                 },
179                                                 {
180                                                     'name': 'person_id',
181                                                     'type': 'int'
182                                                 },
183                                                 {
184                                                     'name': 'remarks',
185                                                     'type': 'string'
186                                                 },
187                                                 {
188                                                     'name': 'person_id_id',
189                                                     'type': 'int'
190                                                 },
191                                                 {
192                                                     'name': 'person_id_office_id',
193                                                     'type': 'int'
194                                                 },
195                                                 {
196                                                     'name': 'person_id_name',
197                                                     'type': 'string'
198                                                 },
199                                                 {
200                                                     'name': 'person_id_phone',
201                                                     'type': 'string'
202                                                 },
203                                                 {
204                                                     'name': 'person_id_fax',
205                                                     'type': 'string'
206                                                 },
207                                                 {
208                                                     'name': 'person_id_email',
209                                                     'type': 'string'
210                                                 },
211                                                 {
212                                                     'name': 'person_id_company_id',
213                                                     'type': 'int'
214                                                 },
215                                                 {
216                                                     'name': 'person_id_role',
217                                                     'type': 'string'
218                                                 },
219                                                 {
220                                                     'name': 'person_id_active',
221                                                     'type': 'int'
222                                                 },
223                                                 {
224                                                     'name': 'person_id_remarks',
225                                                     'type': 'string'
226                                                 },
227                                                 {
228                                                     'name': 'person_id_passwd',
229                                                     'type': 'string'
230                                                 },
231                                                 {
232                                                     'name': 'person_id_owner_id',
233                                                     'type': 'int'
234                                                 },
235                                                 {
236                                                     'name': 'person_id_lang',
237                                                     'type': 'string'
238                                                 },
239                                                 {
240                                                     'name': 'person_id_no_reset_sent',
241                                                     'type': 'int'
242                                                 },
243                                                 {
244                                                     'name': 'person_id_action_type',
245                                                     'type': 'string'
246                                                 },
247                                                 {
248                                                     'name': 'person_id_project_id',
249                                                     'type': 'int'
250                                                 },
251                                                 {
252                                                     'name': 'person_id_deleted_by',
253                                                     'type': 'int'
254                                                 },
255                                                 {
256                                                     'name': 'person_id_deleted_dt',
257                                                     'type': 'date'
258                                                 }
259                                             ]
260                                         }
261                                     }
262                                 },
263                                 {
264                                     xtype: 'TextField',
265                                     xns: Roo.form,
266                                     fieldLabel : 'Onid',
267                                     name : 'onid',
268                                     width : 75
269                                 },
270                                 {
271                                     xtype: 'ComboBox',
272                                     xns: Roo.form,
273                                     allowBlank : 'false',
274                                     editable : 'false',
275                                     emptyText : "Select Person",
276                                     forceSelection : true,
277                                     listWidth : 400,
278                                     loadingText : "Searching...",
279                                     minChars : 2,
280                                     pageSize : 20,
281                                     qtip : "Select Person",
282                                     selectOnFocus : true,
283                                     triggerAction : 'all',
284                                     typeAhead : true,
285                                     width : 300,
286                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
287                                     queryParam : 'query[name]',
288                                     fieldLabel : 'Person',
289                                     valueField : 'id',
290                                     displayField : 'name',
291                                     hiddenName : 'person_id',
292                                     name : 'person_id_name',
293                                     store : {
294                                         xtype: 'Store',
295                                         xns: Roo.data,
296                                         remoteSort : true,
297                                         sortInfo : { direction : 'ASC', field: 'id' },
298                                         listeners : {
299                                             beforeload : function (_self, o){
300                                                 o.params = o.params || {};
301                                                 // set more here
302                                             }
303                                         },
304                                         proxy : {
305                                             xtype: 'HttpProxy',
306                                             xns: Roo.data,
307                                             method : 'GET',
308                                             url : baseURL + '/Roo/Person.php'
309                                         },
310                                         reader : {
311                                             xtype: 'JsonReader',
312                                             xns: Roo.data,
313                                             id : 'id',
314                                             root : 'data',
315                                             totalProperty : 'total',
316                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
317                                         }
318                                     }
319                                 },
320                                 {
321                                     xtype: 'TextField',
322                                     xns: Roo.form,
323                                     fieldLabel : 'Event',
324                                     name : 'event',
325                                     width : 200
326                                 },
327                                 {
328                                     xtype: 'TextField',
329                                     xns: Roo.form,
330                                     fieldLabel : 'Medium',
331                                     name : 'medium',
332                                     width : 200
333                                 },
334                                 {
335                                     xtype: 'TextField',
336                                     xns: Roo.form,
337                                     fieldLabel : 'Active',
338                                     name : 'active',
339                                     width : 75
340                                 },
341                                 {
342                                     xtype: 'Hidden',
343                                     xns: Roo.form,
344                                     name : 'id'
345                                 }
346                             ]
347                         }
348                     ]
349                 }
350             ],
351             center : {
352                 xtype: 'LayoutRegion',
353                 xns: Roo
354             },
355             buttons : [
356                 {
357                     xtype: 'Button',
358                     xns: Roo,
359                     listeners : {
360                         click : function (_self, e)
361                         {
362                             _this.dialog.hide();
363                         }
364                     },
365                     text : "Cancel"
366                 },
367                 {
368                     xtype: 'Button',
369                     xns: Roo,
370                     listeners : {
371                         click : function (_self, e)
372                         {
373                             // do some checks?
374                              
375                             
376                             _this.dialog.el.mask("Saving");
377                             _this.form.doAction("submit");
378                         
379                         }
380                     },
381                     text : "Save"
382                 }
383             ]
384         });
385     }
386 };