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) {
137 parentLayout.getRegion(region).showPanel(this.panel);
140 this.parentLayout = parentLayout;
142 this.layout = new Roo.BorderLayout(
143 parentLayout.getEl().createChild({tag:'div'}),
155 this.tab = parentLayout.add(region,
156 new Roo.NestedLayoutPanel(
163 this.tab.on('activate', function() {
164 _this.delayedCreate();
165 // _this.paging.onClick('refresh');
168 delayedCreate : function ()
176 var refreshPager = function() {
179 this.layout.beginUpdate();
181 var frm = this.layout.getRegion('center').getEl().createChild({tag:'div'});
182 //this.grid = new Roo.grid.EditorGrid(frm, {
183 this.grid = new Roo.grid.Grid(frm, {
187 id: this.id + '-grid',
188 ds: new Roo.data.Store({
190 proxy: new Roo.data.HttpProxy({
191 url: baseURL + '/Roo/Person.html',
194 reader: Pman.Readers.Person,
198 beforeload: function(t, o) {
199 //console.log(o.params);
201 return _this.beforeload(t,o);
205 loadexception : Pman.loadException,
206 update : function (_self, record, operation)
208 if (operation != 'commit') {
211 // only used to change active status.
214 url : baseURL + '/Roo/Person.php',
218 active: record.data.active
221 success : function() {
226 Roo.MessageBox.alert("Error", "saving failed", function() {
227 _this.grid.footer.onClick('first');
238 field: 'name', direction: 'ASC'
241 cm: new Roo.grid.ColumnModel(
244 autoExpandColumn: 'name', // fixme!!!!
250 rowdblclick : function(g, ri, e) {
251 var s = g.getDataSource().getAt(ri).data;
252 if (_this.dialog() && Pman.hasPerm(_this.permName, 'E')) {
253 _this.dialog().show(s,refreshPager);
258 cellclick : function (_self, rowIndex, columnIndex, e)
260 var di = this.colModel.getDataIndex(columnIndex);
261 if (di != 'active') {
265 var rec = _this.grid.ds.getAt(rowIndex);
267 rec.set('active', rec.data.active ? 0 : 1);
270 var el = Roo.select('.x-grid-row-selected').item(3);
271 el.addClass('x-grid-row-fadeout');
272 el.on('transitionend',function(){
273 _this.grid.ds.remove(rec);
274 },this,{single:true});
282 this.panel = this.layout.add('center', new Roo.GridPanel(this.grid , {
285 //background : false,
287 title: this.title || "Staff",
293 if (this.hiddenColumns) {
294 var cm = this.grid.getColumnModel();
295 Roo.each(this.hiddenColumns, function(c) {
296 cm.setHidden(cm.getIndexByDataIndex(c), true);
302 var gridFoot = this.grid.getView().getFooterPanel(true);
303 this.paging = new Roo.PagingToolbar(gridFoot, this.grid.getDataSource(), {
306 displayMsg: "Displaying " + (this.itemDisplayName || "Staff") + " {0} - {1} of {2}",
307 emptyMsg: "No " + (this.itemDisplayName || "Staff") + " found"
309 var grid = this.grid;
312 this.toolbar = new Roo.Toolbar(this.grid.getView().getHeaderPanel(true));
314 var tb = this.toolbar;
317 if (this.parentLayout.getRegion('west') && this.parentLayout.getRegion('west').panels.length) {
320 '<b><i><font color="red">'+
322 "Drag person to add or remove from group" :
323 "Drag person to add or remove from team"
330 //if (this.permName == 'Core.Staff') {
332 this.paging.add( '-',
334 text: "Show old staff",
337 toggleHandler: function(btn,pressed) {
338 _this.showInActive = (pressed ? 1 : 0);
339 btn.setText(pressed ? "Hide old staff": "Show old staff" );
350 this.searchBox = new Roo.form.TextField({
354 specialkey : function(f,e)
357 if (e.getKey() == 13) {
367 var dg = _this.dialog();
371 cls: 'x-btn-text-icon',
372 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
373 hidden : !dg || (_this.newDefaults() === false) || !Pman.hasPerm(this.permName, 'A'),
374 handler : function(){
375 dg.show( _this.newDefaults(), refreshPager );
378 { ///... for contacts stuff...
380 cls: 'x-btn-text-icon',
381 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
382 hidden : !this.bulkAdd() || !Pman.hasPerm(this.permName, 'A'),
383 handler : function(){
385 // Pman.Dialog.PersonBulkAdd.show( { id : 0 }, refreshPager );
386 _this.bulkAdd().show( { id : 0 }, refreshPager );
392 cls: 'x-btn-text-icon',
393 icon: Roo.rootURL + 'images/default/tree/leaf.gif',
394 hidden : !dg || !Pman.hasPerm(this.permName, 'E'),
395 handler : function(){
396 var s = grid.getSelectionModel().getSelections();
397 if (!s.length || (s.length > 1)) {
398 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
401 dg.show( s[0].data,refreshPager);
405 text: "Toogle Active",
406 cls: 'x-btn-text-icon',
407 icon: rootURL + '/Pman/templates/images/trash.gif',
408 hidden : (this.permName != 'Core.Staff') || !Pman.hasPerm(this.permName, 'E'), // SPECIFIC TO STAFF!!!!!!
409 handler : function(){
411 var s = grid.getSelectionModel().getSelections();
413 Roo.MessageBox.alert("Error", "Select People Row");
417 for(var i = 0; i < s.length; i++) {
418 r.push(s[i].data.id);
423 grid.getView().mainWrap.mask("Sending");
427 url: baseURL + '/Roo/Person.html',
430 _toggleActive : r.join(',')
432 success: function(resp) {
433 var res = Pman.processResponse(resp);
434 grid.getView().mainWrap.unmask();
436 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
442 failure: function(act) {
443 grid.getView().mainWrap.unmask();
444 Roo.MessageBox.alert("Error", "Error Sending");
454 cls: 'x-btn-text-icon',
455 hidden : !Pman.hasPerm(_this.permName, 'D'),
456 icon: rootURL + '/Pman/templates/images/trash.gif',
457 handler : function(){
458 Pman.genericDelete(_this, 'Person');
471 icon: rootURL + '/Pman/templates/images/search.gif', // icons can also be specified inline
474 handler : function () {
475 _this.grid.getSelectionModel().clearSelections();
483 icon: rootURL + '/Pman/templates/images/edit-clear.gif', // icons can also be specified inline
485 qtip: "Reset Search",
486 handler : function () {
487 _this.searchBox.setValue('');
488 _this.grid.getSelectionModel().clearSelections();
499 text: "Switch to Selected User?????",
500 hidden : _this.permName != 'Core.Staff' || !Pman.hasPerm('Core.Staff', 'E'),
502 click : function () {
503 var s = grid.getSelectionModel().getSelections();
505 Roo.MessageBox.alert("Error", "Select a Person");
509 url : baseURL+ '/Login.php',
511 'switch' : s[0].data.id
515 success : function() {
516 document.location = baseURL + '?ts=' + Math.random();
519 failure : function(d) {
521 Roo.MessageBox.alert("Error", d);
537 // add stuff to toolbar?
538 //this.innerLayout.endUpdate();
539 this.layout.endUpdate();
545 show: function (parentLayout, region)
547 this.add(parentLayout, region);
548 this.grid.getDataSource().load({
558 c_project_id_code : function(cfg) {
562 dataIndex : 'project_id_code',
565 renderer : function(v,x,r) {
566 return String.format('<span qtip="{0}">{1}</span>',
576 c_name : function(cfg) {
579 // id : (this.id + '-name').toLowerCase(),
583 renderer : function(v,p,r) {
584 if(r.data.active != 1){
585 return String.format('<div style="text-decoration:line-through">{0}</div>', v);
587 return String.format('{0}', v);
592 c_company_id_comptype : function(cfg) {
595 header : "Company Type",
596 dataIndex : 'company_id_comptype',
602 c_company_id_name : function(cfg) {
605 header : "Company / Office",
606 dataIndex : 'company_id_name',
609 renderer: function(v,x,r) {
610 return String.format('{0}{1}{2}',
612 r.data.office_id ? ' / ' : '',
613 r.data.office_id_name);
619 c_office_id_name : function(cfg) {
622 header : "Office / Dept.",
623 dataIndex : 'office_id_name',
629 c_role : function(cfg) {
632 header : "Role / Position",
639 c_phone : function(cfg) {
649 c_fax : function(cfg) {
659 c_email : function(cfg) {
666 renderer : function (v) {
667 return (v.length && v.indexOf('@') > 0 ) ?
668 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
673 c_active : function(cfg) {
677 dataIndex : 'active',
680 renderer : function(v) {
681 // work out what the column is..
683 var state = v> 0 ? '-checked' : '';
685 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
697 // need two version of this
698 // (one can be used as edit + ProjectDirectory ADD)
699 // - the other one needs selection combos's for company / office