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