fix company id findfield
[Pman.Admin] / Pman.Dialog.AdminPerson.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.AdminPerson = {
8
9  _strings : {
10   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
11   '7573b7fd7836c9118dbfb69f3abf3858' :"Change / Set Password",
12   'abb1d799e06329cb0c38276ea918300b' :"Secure passwords",
13   '2b0d7f748b64304e6657207cb03cd8f2' :"Edit / Create Staff Details",
14   '7e17f8478e121357b78646ca5b5d5ac9' :"Displaying Settings  {0} - {1} of {2}",
15   'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
16   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
17   '3544848f820b9d94a3f3871a382cf138' :"New password",
18   '689202409e48743b914713f96d93947c' :"Value",
19   '8a25a3ae30ab6e8ceb5b8c4009a3336f' :"Role / Position",
20   'be5f40c0d2692cf4e9f8be8d389737a5' :"Department / Office",
21   '315fce99b77b7f392bf68d5eb14f88c7' :"Password (type again to confirm)",
22   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
23   'e4709a73a287a5f033f5b1b5142cb74d' :"System Settings",
24   '49ee3087348e8d44e1feda1917443987' :"Name",
25   'a5da1d5de4f3a80e2acf5227283c630d' :"Staff Details",
26   'c373dd4bd4ba0b5d3e0c7522c5629880' :"Select Office",
27   '662de0725ac8055bff7edae51fbf3c78' :"No Settings Found",
28   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
29   'e55f75a29310d7b60f7ac1d390c8ae42' :"Module",
30   'b5a7adde1af5c87d7fd797b6245c2a39' :"Description",
31   'c9cc8cce247e49bae79f15173ce97354' :"Save"
32  },
33  _named_strings : {
34   'secure_password_fieldLabel' : 'abb1d799e06329cb0c38276ea918300b' /* Secure passwords */ ,
35   'role_fieldLabel' : '8a25a3ae30ab6e8ceb5b8c4009a3336f' /* Role / Position */ ,
36   'name_fieldLabel' : '49ee3087348e8d44e1feda1917443987' /* Name */ ,
37   'office_id_name_emptyText' : 'be5f40c0d2692cf4e9f8be8d389737a5' /* Department / Office */ ,
38   'phone_fieldLabel' : 'bcc254b55c4a1babdf1dcb82c207506b' /* Phone */ ,
39   'passwd1_fieldLabel' : '315fce99b77b7f392bf68d5eb14f88c7' /* Password (type again to confirm) */ ,
40   'office_id_name_fieldLabel' : 'be5f40c0d2692cf4e9f8be8d389737a5' /* Department / Office */ ,
41   'office_id_name_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
42   'email_fieldLabel' : 'ce8ae9da5b7cd6c3df2929543a9af92d' /* Email */ ,
43   'office_id_name_qtip' : 'c373dd4bd4ba0b5d3e0c7522c5629880' /* Select Office */ 
44  },
45
46  dialog : false,
47  callback:  false,
48
49  show : function(data, cb)
50  {
51   if (!this.dialog) {
52    this.create();
53   }
54
55   this.callback = cb;
56   this.data = data;
57   this.dialog.show.apply(this.dialog,  Array.prototype.slice.call(arguments).slice(2));
58   if (this.form) {
59    this.form.reset();
60    this.form.setValues(data);
61    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
62   }
63
64  },
65
66  create : function()
67  {
68    var _this = this;
69    this.dialog = Roo.factory({
70     xtype : 'LayoutDialog',
71     closable : false,
72     collapsible : false,
73     height : 400,
74     modal : true,
75     resizable : false,
76     title : _this._strings['2b0d7f748b64304e6657207cb03cd8f2'] /* Edit / Create Staff Details */,
77     width : 450,
78     xns : Roo,
79     '|xns' : 'Roo',
80     center : {
81      xtype : 'LayoutRegion',
82      xns : Roo,
83      '|xns' : 'Roo'
84     },
85     buttons : [
86      {
87       xtype : 'Button',
88       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
89       listeners : {
90        click : function (_self, e)
91         {
92             _this.dialog.hide();
93         }
94       },
95       xns : Roo,
96       '|xns' : 'Roo'
97      },
98      {
99       xtype : 'Button',
100       text : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
101       listeners : {
102        click : function (_self, e)
103         {
104             // do some checks?
105              if (this.form.findField('passwd1')) {
106                 
107                 var p1 = this.form.findField('passwd1').getValue();
108                 var p2 = this.form.findField('passwd2').getValue();
109                 
110                 if (this.sendAfterSave && !p1.length) {
111                     Ext.MessageBox.alert("Error", "You must create a password to send introduction mail");
112                     return;
113                 }
114                 
115                 if (Pman.Login.authUser.id < 0 && !p1.length) {
116                     Ext.MessageBox.alert("Error", "You must create a password for the admin account");
117                     return;
118                 }
119                 
120                 
121                 if (p1.length || p2.length) {
122                     if (p1 != p2) {
123                         Ext.MessageBox.alert("Error", "Passwords do not match");
124                         return;
125                     }
126                 }
127                 
128             
129             }
130             
131          
132             _this.form.doAction("submit");
133         
134         }
135       },
136       xns : Roo,
137       '|xns' : 'Roo'
138      }
139     ],
140     items  : [
141      {
142       xtype : 'ContentPanel',
143       region : 'center',
144       title : _this._strings['a5da1d5de4f3a80e2acf5227283c630d'] /* Staff Details */,
145       xns : Roo,
146       '|xns' : 'Roo',
147       items  : [
148        {
149         xtype : 'Form',
150         labelWidth : 120,
151         method : 'POST',
152         style : 'margin:10px;',
153         url : baseURL + '/Roo/core_person',
154         listeners : {
155          actioncomplete : function(_self,action)
156           {
157               if (action.type == 'setdata') {
158                   _this.dialog.layout.getRegion('center').showPanel(0);
159                  //_this.dialog.el.mask("Loading");
160                  if ( _this.data.id* 1 > 0) { 
161                       this.load({ method: 'GET', params: { '_id' : _this.data.id }});
162                       return;
163                   }
164                   this.findField('company_id').setValue(Pman.Login.authUser.company_id);
165                  return;
166               }
167               if (action.type == 'load') {
168                   _this.dialog.el.unmask();
169                   return;
170               }
171               if (action.type =='submit') {
172               
173                   _this.dialog.el.unmask();
174                   _this.dialog.hide();
175               
176                    if (_this.callback) {
177                       _this.callback.call(_this, _this.form.getValues());
178                    }
179                    _this.form.reset();
180                    return;
181               }
182           },
183          rendered : function (form)
184           {
185               _this.form= form;
186           }
187         },
188         xns : Roo.form,
189         '|xns' : 'Roo.form',
190         items  : [
191          {
192           xtype : 'TextField',
193           allowBlank : true,
194           fieldLabel : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
195           name : 'name',
196           width : 250,
197           xns : Roo.form,
198           '|xns' : 'Roo.form'
199          },
200          {
201           xtype : 'TextField',
202           allowBlank : false,
203           fieldLabel : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
204           name : 'email',
205           width : 250,
206           xns : Roo.form,
207           '|xns' : 'Roo.form'
208          },
209          {
210           xtype : 'TextField',
211           fieldLabel : _this._strings['8a25a3ae30ab6e8ceb5b8c4009a3336f'] /* Role / Position */,
212           name : 'role',
213           width : 250,
214           xns : Roo.form,
215           '|xns' : 'Roo.form'
216          },
217          {
218           xtype : 'TextField',
219           fieldLabel : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
220           name : 'phone',
221           width : 150,
222           xns : Roo.form,
223           '|xns' : 'Roo.form'
224          },
225          {
226           xtype : 'Hidden',
227           name : 'company_id',
228           xns : Roo.form,
229           '|xns' : 'Roo.form'
230          },
231          {
232           xtype : 'ComboBox',
233           allowBlank : true,
234           displayField : 'name',
235           editable : false,
236           emptyText : _this._strings['be5f40c0d2692cf4e9f8be8d389737a5'] /* Department / Office */,
237           fieldLabel : _this._strings['be5f40c0d2692cf4e9f8be8d389737a5'] /* Department / Office */,
238           forceSelection : true,
239           hiddenName : 'office_id',
240           listWidth : 400,
241           loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
242           minChars : 2,
243           name : 'office_id_name',
244           pageSize : 20,
245           qtip : _this._strings['c373dd4bd4ba0b5d3e0c7522c5629880'] /* Select Office */,
246           queryParam : 'query[name]',
247           selectOnFocus : true,
248           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>',
249           triggerAction : 'all',
250           typeAhead : true,
251           valueField : 'id',
252           width : 250,
253           listeners : {
254            beforequery : function (combo, query, forceAll, cancel, e)
255             {
256                     var coid = _this.form.findField('company_id').getValue();
257                     if (coid < 1 ) {
258                         Ext.MessageBox.alert("Error", "Select An Company First");
259                         return false;
260                     }
261             }
262           },
263           xns : Roo.form,
264           '|xns' : 'Roo.form',
265           store : {
266            xtype : 'Store',
267            remoteSort : true,
268            sortInfo : { direction : 'ASC', field: 'id' },
269            listeners : {
270             beforeload : function (_self, o){
271                  o.params = o.params || {};
272                  var coid = _this.form.findField('company_id').getValue();
273                  o.params.company_id = coid;
274              }
275            },
276            xns : Roo.data,
277            '|xns' : 'Roo.data',
278            proxy : {
279             xtype : 'HttpProxy',
280             method : 'GET',
281             url : baseURL + '/Roo/core_office',
282             xns : Roo.data,
283             '|xns' : 'Roo.data'
284            },
285            reader : {
286             xtype : 'JsonReader',
287             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
288             id : 'id',
289             root : 'data',
290             totalProperty : 'total',
291             xns : Roo.data,
292             '|xns' : 'Roo.data'
293            }
294           }
295          },
296          {
297           xtype : 'Hidden',
298           name : 'id',
299           xns : Roo.form,
300           '|xns' : 'Roo.form'
301          },
302          {
303           xtype : 'FieldSet',
304           labelWidth : 200,
305           legend : _this._strings['7573b7fd7836c9118dbfb69f3abf3858'] /* Change / Set Password */,
306           style : 'width:370px',
307           xns : Roo.form,
308           '|xns' : 'Roo.form',
309           items  : [
310            {
311             xtype : 'SecurePass',
312             fieldLabel : _this._strings['3544848f820b9d94a3f3871a382cf138'] /* New password */,
313             inputType : 'password',
314             name : 'passwd1',
315             width : 150,
316             xns : Roo.form,
317             '|xns' : 'Roo.form'
318            },
319            {
320             xtype : 'TextField',
321             allowBlank : true,
322             fieldLabel : _this._strings['315fce99b77b7f392bf68d5eb14f88c7'] /* Password (type again to confirm) */,
323             inputType : 'password',
324             name : 'passwd1',
325             width : 150,
326             xns : Roo.form,
327             '|xns' : 'Roo.form'
328            },
329            {
330             xtype : 'Checkbox',
331             checked : true,
332             fieldLabel : _this._strings['abb1d799e06329cb0c38276ea918300b'] /* Secure passwords */,
333             inputValue : 1,
334             name : 'secure_password',
335             valueOff : 0,
336             listeners : {
337              check : function (_self, checked)
338               {
339                   this.form.findField('passwd1').insecure = false;
340                       
341                   if(!checked){
342                       this.form.findField('passwd1').insecure = true;
343                   }
344               }
345             },
346             xns : Roo.form,
347             '|xns' : 'Roo.form'
348            }
349           ]
350          }
351         ]
352        }
353       ]
354      },
355      {
356       xtype : 'GridPanel',
357       background : true,
358       fitContainer : true,
359       fitToframe : true,
360       region : 'center',
361       title : _this._strings['e4709a73a287a5f033f5b1b5142cb74d'] /* System Settings */,
362       listeners : {
363        activate : function() {
364             _this.panel = this;
365          
366             if (_this.grid) {
367                 _this.grid.footer.onClick('first');
368             }
369         }
370       },
371       xns : Roo,
372       '|xns' : 'Roo',
373       grid : {
374        xtype : 'Grid',
375        autoExpandColumn : 'data',
376        loadMask : true,
377        listeners : {
378         render : function() 
379          {
380              _this.grid = this; 
381              //_this.dialog = Pman.Dialog.FILL_IN
382              if (_this.panel.active) {
383                 this.footer.onClick('first');
384              }
385          },
386         rowdblclick : function (_self, rowIndex, e)
387          {
388              if (!_this.dialog) {
389                   return;
390               }
391              _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
392                  _this.grid.footer.onClick('refresh');
393              }); 
394          }
395        },
396        xns : Roo.grid,
397        '|xns' : 'Roo.grid',
398        footer : {
399         xtype : 'PagingToolbar',
400         displayInfo : true,
401         displayMsg : _this._strings['7e17f8478e121357b78646ca5b5d5ac9'] /* Displaying Settings  {0} - {1} of {2} */,
402         emptyMsg : _this._strings['662de0725ac8055bff7edae51fbf3c78'] /* No Settings Found */,
403         pageSize : 25,
404         xns : Roo,
405         '|xns' : 'Roo'
406        },
407        toolbar : {
408         xtype : 'Toolbar',
409         xns : Roo,
410         '|xns' : 'Roo',
411         items  : [
412          {
413           xtype : 'Fill',
414           xns : Roo.Toolbar,
415           '|xns' : 'Roo.Toolbar'
416          },
417          {
418           xtype : 'Button',
419           cls : 'x-btn-text-icon',
420           icon : rootURL + '/Pman/templates/images/trash.gif',
421           text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
422           listeners : {
423            click : function()
424             {
425                  Pman.genericDelete(_this, 'core_person_settings'); 
426             }
427           },
428           xns : Roo.Toolbar,
429           '|xns' : 'Roo.Toolbar'
430          }
431         ]
432        },
433        dataSource : {
434         xtype : 'Store',
435         remoteSort : true,
436         sortInfo : { field : 'name', direction: 'ASC' },
437         listeners : {
438          beforeload : function (_self, o)
439           {
440             
441               o.params = o.params ? o.params : {};
442               o.params.person_id =  _this.form.findField('id').getValue();
443               
444              
445           }
446         },
447         xns : Roo.data,
448         '|xns' : 'Roo.data',
449         proxy : {
450          xtype : 'HttpProxy',
451          method : 'GET',
452          url : baseURL + '/Roo/core_person_settings',
453          xns : Roo.data,
454          '|xns' : 'Roo.data'
455         },
456         reader : {
457          xtype : 'JsonReader',
458          id : 'id',
459          root : 'data',
460          totalProperty : 'total',
461          xns : Roo.data,
462          '|xns' : 'Roo.data'
463         }
464        },
465        sm : {
466         xtype : 'RowSelectionModel',
467         singleSelect : true,
468         listeners : {
469          afterselectionchange : function (_self)
470           {
471               // load project members.
472           }
473         },
474         xns : Roo.grid,
475         '|xns' : 'Roo.grid'
476        },
477        colModel : [
478         {
479          xtype : 'ColumnModel',
480          dataIndex : 'scope',
481          header : _this._strings['e55f75a29310d7b60f7ac1d390c8ae42'] /* Module */,
482          sortable : true,
483          width : 120,
484          xns : Roo.grid,
485          '|xns' : 'Roo.grid'
486         },
487         {
488          xtype : 'ColumnModel',
489          dataIndex : 'description',
490          header : _this._strings['b5a7adde1af5c87d7fd797b6245c2a39'] /* Description */,
491          renderer : function(v) { return String.format('{0}', v); },
492          sortable : true,
493          width : 150,
494          xns : Roo.grid,
495          '|xns' : 'Roo.grid'
496         },
497         {
498          xtype : 'ColumnModel',
499          dataIndex : 'data',
500          header : _this._strings['689202409e48743b914713f96d93947c'] /* Value */,
501          renderer : function(v) { return String.format('{0}', v); },
502          sortable : true,
503          width : 200,
504          xns : Roo.grid,
505          '|xns' : 'Roo.grid'
506         }
507        ]
508       }
509      }
510     ]
511    });
512  }
513 };