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