1 //<script type="text/javascript">
5 * generic person list - used by perms. and staff lists.
11 Pman.Tab.PersonList = function(config)
13 Ext.apply(this, config);
16 Pman.Tab.PersonList.prototype = {
18 //--- things that should be set!!!!
19 id : '', // should be set to something!
20 type : 0, // means!! = 0 = Groups (perms) 1= teams - loose grouping..
22 hiddenColumns: false, // lsit of cols to hide..
23 itemDisplayName : false, /// eg "Staff Employees / Contacts etc."
24 permName : 'Core.Person', // or 'Core.Staff'
25 getLeftSelections : function() { return []; },
28 // beforeload handler... -- override on extended versions..
29 beforeload: function(t, o) {
30 //console.log(o.params);
32 alert('person list not configured');
34 var tms = _this.getLeftSelections();
37 o.params['query[in_group]'] = tms[0].data.id;
39 o.params['query[name]'] = this.searchBox.getValue();
40 o.params['query[type]'] = this.type; // group type..
41 o.params['query[person_internal_only_all]'] = 1;
42 o.params['query[person_inactive]'] = this.showInActive ? 0 : 1;
48 alert('person list not configured');
52 this.c_office_id_name(),
62 alert('person list not configured');
64 return Pman.Dialog.PersonStaff;
66 bulkAdd : function() {
67 //return Pman.Dialog.PersonBulkAdd
70 newDefaults : function() {
71 alert('person list not configured');
76 company_id : Pman.Login.authUser.company_id,
77 company_id_name : Pman.Login.authUser.company_id_name,
78 company_id_address : Pman.Login.authUser.company_id_address,
79 company_id_tel : Pman.Login.authUser.company_id_tel,
80 company_id_fax : Pman.Login.authUser.company_id_fax
86 /// --- end extendable bits...
90 showInActive : 0, // toggle var for hiding and showing active staff..
98 refreshWestPanel : function() /// used wher???
100 var actpan = this.parentLayout.getRegion('west').getActivePanel();
101 if (actpan && actpan.controller) {
102 actpan.controller.paging.onClick('refresh');
107 if (!actpan || !actpan.id) {
110 Pman.Tab[actpan.id].refresh();
115 this.delayedCreate();
117 this.paging.onClick('refresh');
120 loadFirst: function(){
122 this.delayedCreate();
124 this.paging.onClick('first');
129 add : function(parentLayout, region) {
133 parentLayout.getRegion(region).showPanel(this.panel);
136 this.parentLayout = parentLayout;
138 this.layout = new Ext.BorderLayout(
139 parentLayout.getEl().createChild({tag:'div'}),
151 this.tab = parentLayout.add(region, new Ext.NestedLayoutPanel(
152 this.layout, {title: this.title, background: true, controller : this}));
154 this.tab.on('activate', function() {
155 _this.delayedCreate();
156 // _this.paging.onClick('refresh');
159 delayedCreate : function ()
167 var refreshPager = function() {
170 this.layout.beginUpdate();
172 var frm = this.layout.getRegion('center').getEl().createChild({tag:'div'});
173 //this.grid = new Ext.grid.EditorGrid(frm, {
174 this.grid = new Ext.grid.Grid(frm, {
178 id: this.id + '-grid',
179 ds: new Ext.data.Store({
181 proxy: new Ext.data.HttpProxy({
182 url: baseURL + '/Roo/Person.html',
185 reader: Pman.Readers.Person,
189 beforeload: function(t, o) {
190 //console.log(o.params);
192 return _this.beforeload(t,o);
196 loadexception : Pman.loadException
200 field: 'name', direction: 'ASC'
203 cm: new Ext.grid.ColumnModel(
206 autoExpandColumn: _this.id + '-name' , // fixme!!!!
212 rowdblclick : function(g, ri, e) {
213 var s = g.getDataSource().getAt(ri).data;
214 if (_this.dialog() && Pman.hasPerm(_this.permName, 'E')) {
215 _this.dialog().show(s,refreshPager);
225 this.panel = this.layout.add('center', new Ext.GridPanel(this.grid , {
229 title: this.title || "Staff",
235 if (this.hiddenColumns) {
236 var cm = this.grid.getColumnModel();
237 Roo.each(this.hiddenColumns, function(c) {
238 cm.setHidden(cm.getIndexByDataIndex(c), true);
244 var gridFoot = this.grid.getView().getFooterPanel(true);
245 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
248 displayMsg: "Displaying " + (this.itemDisplayName || "Staff") + " {0} - {1} of {2}",
249 emptyMsg: "No " + (this.itemDisplayName || "Staff") + " found"
251 var grid = this.grid;
254 this.toolbar = new Ext.Toolbar(this.grid.getView().getHeaderPanel(true));
256 var tb = this.toolbar;
259 if (this.parentLayout.getRegion('west') && this.parentLayout.getRegion('west').panels.length) {
262 '<b><i><font color="red">'+
264 "Drag person to add or remove from group" :
265 "Drag person to add or remove from team"
272 if (this.permName == 'Core.Staff') {
274 this.paging.add( '-',
276 text: "Show old staff",
279 toggleHandler: function(btn,pressed) {
280 _this.showInActive = (pressed ? 1 : 0);
281 btn.setText(pressed ? "Hide old staff": "Show old staff" );
292 this.searchBox = new Ext.form.TextField({
296 specialkey : function(f,e)
299 if (e.getKey() == 13) {
309 var dg = _this.dialog();
313 cls: 'x-btn-text-icon',
314 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
315 hidden : !dg || (_this.newDefaults() === false) || !Pman.hasPerm(this.permName, 'A'),
316 handler : function(){
317 dg.show( _this.newDefaults(), refreshPager );
320 { ///... for contacts stuff...
322 cls: 'x-btn-text-icon',
323 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
324 hidden : !this.bulkAdd() || !Pman.hasPerm(this.permName, 'A'),
325 handler : function(){
327 // Pman.Dialog.PersonBulkAdd.show( { id : 0 }, refreshPager );
328 _this.bulkAdd().show( { id : 0 }, refreshPager );
334 cls: 'x-btn-text-icon',
335 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
336 hidden : !dg || !Pman.hasPerm(this.permName, 'E'),
337 handler : function(){
338 var s = grid.getSelectionModel().getSelections();
339 if (!s.length || (s.length > 1)) {
340 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
343 dg.show( s[0].data,refreshPager);
347 text: "Toogle Active",
348 cls: 'x-btn-text-icon',
349 icon: rootURL + '/Pman/templates/images/trash.gif',
350 hidden : (this.permName != 'Core.Staff') || !Pman.hasPerm(this.permName, 'E'), // SPECIFIC TO STAFF!!!!!!
351 handler : function(){
353 var s = grid.getSelectionModel().getSelections();
355 Ext.MessageBox.alert("Error", "Select People Row");
359 for(var i = 0; i < s.length; i++) {
360 r.push(s[i].data.id);
365 grid.getView().mainWrap.mask("Sending");
369 url: baseURL + '/Roo/Person.html',
372 _toggleActive : r.join(',')
374 success: function(resp) {
375 var res = Pman.processResponse(resp);
376 grid.getView().mainWrap.unmask();
378 Ext.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
384 failure: function(act) {
385 grid.getView().mainWrap.unmask();
386 Ext.MessageBox.alert("Error", "Error Sending");
395 cls: 'x-btn-text-icon',
396 hidden : (this.permName == 'Core.Staff') || !Pman.hasPerm('Core.Person', 'D') || this.hideDelete,
397 icon: rootURL + '/Pman/templates/images/trash.gif',
398 handler : function(){
399 Pman.genericDelete(_this, 'Person');
412 icon: rootURL + '/Pman/templates/images/search.gif', // icons can also be specified inline
415 handler : function () {
416 _this.grid.getSelectionModel().clearSelections();
424 icon: rootURL + '/Pman/templates/images/edit-clear.gif', // icons can also be specified inline
426 qtip: "Reset Search",
427 handler : function () {
428 _this.searchBox.setValue('');
429 _this.grid.getSelectionModel().clearSelections();
440 // add stuff to toolbar?
441 //this.innerLayout.endUpdate();
442 this.layout.endUpdate();
448 show: function (parentLayout, region)
450 this.add(parentLayout, region);
451 this.grid.getDataSource().load({
461 c_project_id_code : function(cfg) {
465 dataIndex : 'project_id_code',
468 renderer : function(v,x,r) {
469 return String.format('<span qtip="{0}">{1}</span>',
479 c_name : function(cfg) {
482 id : this.id + '-name',
489 c_company_id_comptype : function(cfg) {
492 header : "Company Type",
493 dataIndex : 'company_id_comptype',
499 c_company_id_name : function(cfg) {
502 header : "Company / Office",
503 dataIndex : 'company_id_name',
506 renderer: function(v,x,r) {
507 return String.format('{0}{1}{2}',
509 r.data.office_id ? ' / ' : '',
510 r.data.office_id_name);
516 c_office_id_name : function(cfg) {
519 header : "Office / Dept.",
520 dataIndex : 'office_id_name',
526 c_role : function(cfg) {
529 header : "Role / Position",
536 c_phone : function(cfg) {
546 c_fax : function(cfg) {
556 c_email : function(cfg) {
563 renderer : function (v) {
564 return (v.length && v.indexOf('@') > 0 ) ?
565 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
570 c_active : function(cfg) {
574 dataIndex : 'active',
577 renderer : function(v) {
578 // work out what the column is..
580 var state = v> 0 ? '-checked' : '';
582 return '<img class="x-grid-check-icon' + state + '" src="' + Ext.BLANK_IMAGE_URL + '"/>';
594 // need two version of this
595 // (one can be used as edit + ProjectDirectory ADD)
596 // - the other one needs selection combos's for company / office