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);
220 cellclick : function (_self, rowIndex, columnIndex, e)
222 var di = this.colModel.getDataIndex(colIndex);
223 if (di != 'active') {
227 var rec = _this.grid.ds.getAt(rowIndex);
229 rec.set('active', rec.data.active ? 0 : 1);
240 this.panel = this.layout.add('center', new Ext.GridPanel(this.grid , {
244 title: this.title || "Staff",
250 if (this.hiddenColumns) {
251 var cm = this.grid.getColumnModel();
252 Roo.each(this.hiddenColumns, function(c) {
253 cm.setHidden(cm.getIndexByDataIndex(c), true);
259 var gridFoot = this.grid.getView().getFooterPanel(true);
260 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
263 displayMsg: "Displaying " + (this.itemDisplayName || "Staff") + " {0} - {1} of {2}",
264 emptyMsg: "No " + (this.itemDisplayName || "Staff") + " found"
266 var grid = this.grid;
269 this.toolbar = new Ext.Toolbar(this.grid.getView().getHeaderPanel(true));
271 var tb = this.toolbar;
274 if (this.parentLayout.getRegion('west') && this.parentLayout.getRegion('west').panels.length) {
277 '<b><i><font color="red">'+
279 "Drag person to add or remove from group" :
280 "Drag person to add or remove from team"
287 if (this.permName == 'Core.Staff') {
289 this.paging.add( '-',
291 text: "Show old staff",
294 toggleHandler: function(btn,pressed) {
295 _this.showInActive = (pressed ? 1 : 0);
296 btn.setText(pressed ? "Hide old staff": "Show old staff" );
307 this.searchBox = new Ext.form.TextField({
311 specialkey : function(f,e)
314 if (e.getKey() == 13) {
324 var dg = _this.dialog();
328 cls: 'x-btn-text-icon',
329 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
330 hidden : !dg || (_this.newDefaults() === false) || !Pman.hasPerm(this.permName, 'A'),
331 handler : function(){
332 dg.show( _this.newDefaults(), refreshPager );
335 { ///... for contacts stuff...
337 cls: 'x-btn-text-icon',
338 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
339 hidden : !this.bulkAdd() || !Pman.hasPerm(this.permName, 'A'),
340 handler : function(){
342 // Pman.Dialog.PersonBulkAdd.show( { id : 0 }, refreshPager );
343 _this.bulkAdd().show( { id : 0 }, refreshPager );
349 cls: 'x-btn-text-icon',
350 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
351 hidden : !dg || !Pman.hasPerm(this.permName, 'E'),
352 handler : function(){
353 var s = grid.getSelectionModel().getSelections();
354 if (!s.length || (s.length > 1)) {
355 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
358 dg.show( s[0].data,refreshPager);
362 text: "Toogle Active",
363 cls: 'x-btn-text-icon',
364 icon: rootURL + '/Pman/templates/images/trash.gif',
365 hidden : (this.permName != 'Core.Staff') || !Pman.hasPerm(this.permName, 'E'), // SPECIFIC TO STAFF!!!!!!
366 handler : function(){
368 var s = grid.getSelectionModel().getSelections();
370 Ext.MessageBox.alert("Error", "Select People Row");
374 for(var i = 0; i < s.length; i++) {
375 r.push(s[i].data.id);
380 grid.getView().mainWrap.mask("Sending");
384 url: baseURL + '/Roo/Person.html',
387 _toggleActive : r.join(',')
389 success: function(resp) {
390 var res = Pman.processResponse(resp);
391 grid.getView().mainWrap.unmask();
393 Ext.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
399 failure: function(act) {
400 grid.getView().mainWrap.unmask();
401 Ext.MessageBox.alert("Error", "Error Sending");
410 cls: 'x-btn-text-icon',
411 hidden : (this.permName == 'Core.Staff') || !Pman.hasPerm('Core.Person', 'D') || this.hideDelete,
412 icon: rootURL + '/Pman/templates/images/trash.gif',
413 handler : function(){
414 Pman.genericDelete(_this, 'Person');
427 icon: rootURL + '/Pman/templates/images/search.gif', // icons can also be specified inline
430 handler : function () {
431 _this.grid.getSelectionModel().clearSelections();
439 icon: rootURL + '/Pman/templates/images/edit-clear.gif', // icons can also be specified inline
441 qtip: "Reset Search",
442 handler : function () {
443 _this.searchBox.setValue('');
444 _this.grid.getSelectionModel().clearSelections();
455 // add stuff to toolbar?
456 //this.innerLayout.endUpdate();
457 this.layout.endUpdate();
463 show: function (parentLayout, region)
465 this.add(parentLayout, region);
466 this.grid.getDataSource().load({
476 c_project_id_code : function(cfg) {
480 dataIndex : 'project_id_code',
483 renderer : function(v,x,r) {
484 return String.format('<span qtip="{0}">{1}</span>',
494 c_name : function(cfg) {
497 id : this.id + '-name',
504 c_company_id_comptype : function(cfg) {
507 header : "Company Type",
508 dataIndex : 'company_id_comptype',
514 c_company_id_name : function(cfg) {
517 header : "Company / Office",
518 dataIndex : 'company_id_name',
521 renderer: function(v,x,r) {
522 return String.format('{0}{1}{2}',
524 r.data.office_id ? ' / ' : '',
525 r.data.office_id_name);
531 c_office_id_name : function(cfg) {
534 header : "Office / Dept.",
535 dataIndex : 'office_id_name',
541 c_role : function(cfg) {
544 header : "Role / Position",
551 c_phone : function(cfg) {
561 c_fax : function(cfg) {
571 c_email : function(cfg) {
578 renderer : function (v) {
579 return (v.length && v.indexOf('@') > 0 ) ?
580 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
585 c_active : function(cfg) {
589 dataIndex : 'active',
592 renderer : function(v) {
593 // work out what the column is..
595 var state = v> 0 ? '-checked' : '';
597 return '<img class="x-grid-check-icon' + state + '" src="' + Ext.BLANK_IMAGE_URL + '"/>';
609 // need two version of this
610 // (one can be used as edit + ProjectDirectory ADD)
611 // - the other one needs selection combos's for company / office