1 //<script type="text/javascript">
5 * generic person list - used by perms. and staff lists.
7 * -- this is probably depreciated now..
13 Pman.Tab.PersonList = function(config)
15 Roo.apply(this, config);
18 Pman.Tab.PersonList.prototype = {
20 //--- things that should be set!!!!
21 id : '', // should be set to something!
22 type : 0, // means!! = 0 = Groups (perms) 1= teams - loose grouping..
24 hiddenColumns: false, // lsit of cols to hide..
25 itemDisplayName : false, /// eg "Staff Employees / Contacts etc."
26 permName : 'Core.Person', // or 'Core.Staff'
27 getLeftSelections : function() { return []; },
30 // beforeload handler... -- override on extended versions..
31 beforeload: function(t, o) {
32 //console.log(o.params);
34 alert('person list not configured');
37 var tms = _this.getLeftSelections();
40 o.params['query[in_group]'] = tms[0].data.id;
42 o.params['query[name]'] = this.searchBox.getValue();
43 o.params['query[type]'] = this.type; // group type..
44 o.params['query[person_internal_only_all]'] = 1;
45 o.params['query[person_inactive]'] = this.showInActive ? 0 : 1;
52 alert('person list not configured');
56 this.c_office_id_name(),
66 alert('person list not configured');
68 return Pman.Dialog.PersonStaff;
70 bulkAdd : function() {
71 //return Pman.Dialog.PersonBulkAdd
74 newDefaults : function() {
75 alert('person list not configured');
80 company_id : Pman.Login.authUser.company_id,
81 company_id_name : Pman.Login.authUser.company_id_name,
82 company_id_address : Pman.Login.authUser.company_id_address,
83 company_id_tel : Pman.Login.authUser.company_id_tel,
84 company_id_fax : Pman.Login.authUser.company_id_fax
90 /// --- end extendable bits...
94 showInActive : 0, // toggle var for hiding and showing active staff..
102 refreshWestPanel : function() /// used wher???
104 var actpan = this.parentLayout.getRegion('west').getActivePanel();
105 if (actpan && actpan.controller) {
106 actpan.controller.paging.onClick('refresh');
111 if (!actpan || !actpan.id) {
114 Pman.Tab[actpan.id].refresh();
119 this.delayedCreate();
121 this.paging.onClick('refresh');
124 loadFirst: function(){
126 this.delayedCreate();
128 this.paging.onClick('first');
133 add : function(parentLayout, region) {
135 Roo.log('PersonList add called!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
139 parentLayout.getRegion(region).showPanel(this.panel);
142 this.parentLayout = parentLayout;
144 this.layout = new Roo.BorderLayout(
145 parentLayout.getEl().createChild({tag:'div'}),
157 this.tab = parentLayout.add(region,
158 new Roo.NestedLayoutPanel(
165 this.tab.on('activate', function() {
166 _this.delayedCreate();
167 // _this.paging.onClick('refresh');
170 delayedCreate : function ()
178 var refreshPager = function() {
181 this.layout.beginUpdate();
183 var frm = this.layout.getRegion('center').getEl().createChild({tag:'div'});
184 //this.grid = new Roo.grid.EditorGrid(frm, {
185 this.grid = new Roo.grid.Grid(frm, {
189 id: this.id + '-grid',
190 ds: new Roo.data.Store({
192 proxy: new Roo.data.HttpProxy({
193 url: baseURL + '/Roo/Person.html',
196 reader: Pman.Readers.Person,
200 beforeload: function(t, o) {
201 //console.log(o.params);
203 return _this.beforeload(t,o);
207 loadexception : Pman.loadException,
208 update : function (_self, record, operation)
210 if (operation != 'commit') {
213 // only used to change active status.
216 url : baseURL + '/Roo/Person.php',
220 active: record.data.active
223 success : function() {
228 Roo.MessageBox.alert("Error", "saving failed", function() {
229 _this.grid.footer.onClick('first');
240 field: 'name', direction: 'ASC'
243 cm: new Roo.grid.ColumnModel(
246 autoExpandColumn: 'name', // fixme!!!!
252 rowdblclick : function(g, ri, e) {
253 var s = g.getDataSource().getAt(ri).data;
254 if (_this.dialog() && Pman.hasPerm(_this.permName, 'E')) {
255 _this.dialog().show(s,refreshPager);
260 cellclick : function (_self, rowIndex, columnIndex, e)
262 var di = this.colModel.getDataIndex(columnIndex);
263 if (di != 'active') {
267 var rec = _this.grid.ds.getAt(rowIndex);
269 rec.set('active', rec.data.active ? 0 : 1);
272 var el = Roo.select('.x-grid-row-selected').item(3);
273 el.addClass('x-grid-row-fadeout');
274 el.on('transitionend',function(){
275 _this.grid.ds.remove(rec);
276 },this,{single:true});
284 this.panel = this.layout.add('center', new Roo.GridPanel(this.grid , {
287 //background : false,
289 title: this.title || "Staff",
295 if (this.hiddenColumns) {
296 var cm = this.grid.getColumnModel();
297 Roo.each(this.hiddenColumns, function(c) {
298 cm.setHidden(cm.getIndexByDataIndex(c), true);
304 var gridFoot = this.grid.getView().getFooterPanel(true);
305 this.paging = new Roo.PagingToolbar(gridFoot, this.grid.getDataSource(), {
308 displayMsg: "Displaying " + (this.itemDisplayName || "Staff") + " {0} - {1} of {2}",
309 emptyMsg: "No " + (this.itemDisplayName || "Staff") + " found"
311 var grid = this.grid;
314 this.toolbar = new Roo.Toolbar(this.grid.getView().getHeaderPanel(true));
316 var tb = this.toolbar;
319 if (this.parentLayout.getRegion('west') && this.parentLayout.getRegion('west').panels.length) {
322 '<b><i><font color="red">'+
324 "Drag person to add or remove from group" :
325 "Drag person to add or remove from team"
332 //if (this.permName == 'Core.Staff') {
334 this.paging.add( '-',
336 text: "Show old staff",
339 toggleHandler: function(btn,pressed) {
340 _this.showInActive = (pressed ? 1 : 0);
341 btn.setText(pressed ? "Hide old staff": "Show old staff" );
352 this.searchBox = new Roo.form.TextField({
356 specialkey : function(f,e)
359 if (e.getKey() == 13) {
369 var dg = _this.dialog();
373 cls: 'x-btn-text-icon',
374 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
375 hidden : !dg || (_this.newDefaults() === false) || !Pman.hasPerm(this.permName, 'A'),
376 handler : function(){
377 dg.show( _this.newDefaults(), refreshPager );
380 { ///... for contacts stuff...
382 cls: 'x-btn-text-icon',
383 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
384 hidden : !this.bulkAdd() || !Pman.hasPerm(this.permName, 'A'),
385 handler : function(){
387 // Pman.Dialog.PersonBulkAdd.show( { id : 0 }, refreshPager );
388 _this.bulkAdd().show( { id : 0 }, refreshPager );
394 cls: 'x-btn-text-icon',
395 icon: Roo.rootURL + 'images/default/tree/leaf.gif',
396 hidden : !dg || !Pman.hasPerm(this.permName, 'E'),
397 handler : function(){
398 var s = grid.getSelectionModel().getSelections();
399 if (!s.length || (s.length > 1)) {
400 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
403 dg.show( s[0].data,refreshPager);
407 text: "Toogle Active",
408 cls: 'x-btn-text-icon',
409 icon: rootURL + '/Pman/templates/images/trash.gif',
410 hidden : (this.permName != 'Core.Staff') || !Pman.hasPerm(this.permName, 'E'), // SPECIFIC TO STAFF!!!!!!
411 handler : function(){
413 var s = grid.getSelectionModel().getSelections();
415 Roo.MessageBox.alert("Error", "Select People Row");
419 for(var i = 0; i < s.length; i++) {
420 r.push(s[i].data.id);
425 grid.getView().mainWrap.mask("Sending");
429 url: baseURL + '/Roo/Person.html',
432 _toggleActive : r.join(',')
434 success: function(resp) {
435 var res = Pman.processResponse(resp);
436 grid.getView().mainWrap.unmask();
438 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
444 failure: function(act) {
445 grid.getView().mainWrap.unmask();
446 Roo.MessageBox.alert("Error", "Error Sending");
456 cls: 'x-btn-text-icon',
457 hidden : !Pman.hasPerm(_this.permName, 'D'),
458 icon: rootURL + '/Pman/templates/images/trash.gif',
459 handler : function(){
460 Pman.genericDelete(_this, 'Person');
473 icon: rootURL + '/Pman/templates/images/search.gif', // icons can also be specified inline
476 handler : function () {
477 _this.grid.getSelectionModel().clearSelections();
485 icon: rootURL + '/Pman/templates/images/edit-clear.gif', // icons can also be specified inline
487 qtip: "Reset Search",
488 handler : function () {
489 _this.searchBox.setValue('');
490 _this.grid.getSelectionModel().clearSelections();
501 text: "Switch to Selected User",
502 hidden : _this.permName != 'Core.Staff' || !Pman.hasPerm('Core.Staff', 'E'),
504 click : function () {
505 var s = grid.getSelectionModel().getSelections();
507 Roo.MessageBox.alert("Error", "Select a Person");
511 url : baseURL+ '/Login.php',
513 'switch' : s[0].data.id
517 success : function() {
518 document.location = baseURL + '?ts=' + Math.random();
521 failure : function(d) {
523 Roo.MessageBox.alert("Error", d);
539 // add stuff to toolbar?
540 //this.innerLayout.endUpdate();
541 this.layout.endUpdate();
547 show: function (parentLayout, region)
549 this.add(parentLayout, region);
550 this.grid.getDataSource().load({
560 c_project_id_code : function(cfg) {
564 dataIndex : 'project_id_code',
567 renderer : function(v,x,r) {
568 return String.format('<span qtip="{0}">{1}</span>',
578 c_name : function(cfg) {
581 // id : (this.id + '-name').toLowerCase(),
585 renderer : function(v,p,r) {
586 if(r.data.active != 1){
587 return String.format('<div style="text-decoration:line-through">{0}</div>', v);
589 return String.format('{0}', v);
594 c_company_id_comptype : function(cfg) {
597 header : "Company Type",
598 dataIndex : 'company_id_comptype',
604 c_company_id_name : function(cfg) {
607 header : "Company / Office",
608 dataIndex : 'company_id_name',
611 renderer: function(v,x,r) {
612 return String.format('{0}{1}{2}',
614 r.data.office_id ? ' / ' : '',
615 r.data.office_id_name);
621 c_office_id_name : function(cfg) {
624 header : "Office / Dept.",
625 dataIndex : 'office_id_name',
631 c_role : function(cfg) {
634 header : "Role / Position",
641 c_phone : function(cfg) {
651 c_fax : function(cfg) {
661 c_email : function(cfg) {
668 renderer : function (v) {
669 return (v.length && v.indexOf('@') > 0 ) ?
670 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
675 c_active : function(cfg) {
679 dataIndex : 'active',
682 renderer : function(v) {
683 // work out what the column is..
685 var state = v> 0 ? '-checked' : '';
687 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
699 // need two version of this
700 // (one can be used as edit + ProjectDirectory ADD)
701 // - the other one needs selection combos's for company / office