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(
162 _this.delayedCreate();
164 this.tab.on('activate', function() {
165 // _this.delayedCreate();
166 // _this.paging.onClick('refresh');
169 delayedCreate : function ()
177 var refreshPager = function() {
180 this.layout.beginUpdate();
182 var frm = this.layout.getRegion('center').getEl().createChild({tag:'div'});
183 //this.grid = new Roo.grid.EditorGrid(frm, {
184 this.grid = new Roo.grid.Grid(frm, {
188 id: this.id + '-grid',
189 ds: new Roo.data.Store({
191 proxy: new Roo.data.HttpProxy({
192 url: baseURL + '/Roo/Person.html',
195 reader: Pman.Readers.Person,
199 beforeload: function(t, o) {
200 //console.log(o.params);
202 return _this.beforeload(t,o);
206 loadexception : Pman.loadException,
207 update : function (_self, record, operation)
209 if (operation != 'commit') {
212 // only used to change active status.
215 url : baseURL + '/Roo/Person.php',
219 active: record.data.active
222 success : function() {
227 Roo.MessageBox.alert("Error", "saving failed", function() {
228 _this.grid.footer.onClick('first');
239 field: 'name', direction: 'ASC'
242 cm: new Roo.grid.ColumnModel(
245 autoExpandColumn: 'name', // fixme!!!!
251 rowdblclick : function(g, ri, e) {
252 var s = g.getDataSource().getAt(ri).data;
253 if (_this.dialog() && Pman.hasPerm(_this.permName, 'E')) {
254 _this.dialog().show(s,refreshPager);
259 cellclick : function (_self, rowIndex, columnIndex, e)
261 var di = this.colModel.getDataIndex(columnIndex);
262 if (di != 'active') {
266 var rec = _this.grid.ds.getAt(rowIndex);
268 rec.set('active', rec.data.active ? 0 : 1);
271 var el = Roo.select('.x-grid-row-selected').item(3);
272 el.addClass('x-grid-row-fadeout');
273 el.on('transitionend',function(){
274 _this.grid.ds.remove(rec);
275 },this,{single:true});
283 this.panel = this.layout.add('center', new Roo.GridPanel(this.grid , {
286 //background : false,
288 title: this.title || "Staff",
294 if (this.hiddenColumns) {
295 var cm = this.grid.getColumnModel();
296 Roo.each(this.hiddenColumns, function(c) {
297 cm.setHidden(cm.getIndexByDataIndex(c), true);
303 var gridFoot = this.grid.getView().getFooterPanel(true);
304 this.paging = new Roo.PagingToolbar(gridFoot, this.grid.getDataSource(), {
307 displayMsg: "Displaying " + (this.itemDisplayName || "Staff") + " {0} - {1} of {2}",
308 emptyMsg: "No " + (this.itemDisplayName || "Staff") + " found"
310 var grid = this.grid;
313 this.toolbar = new Roo.Toolbar(this.grid.getView().getHeaderPanel(true));
315 var tb = this.toolbar;
318 if (this.parentLayout.getRegion('west') && this.parentLayout.getRegion('west').panels.length) {
321 '<b><i><font color="red">'+
323 "Drag person to add or remove from group" :
324 "Drag person to add or remove from team"
331 //if (this.permName == 'Core.Staff') {
333 this.paging.add( '-',
335 text: "Show old staff",
338 toggleHandler: function(btn,pressed) {
339 _this.showInActive = (pressed ? 1 : 0);
340 btn.setText(pressed ? "Hide old staff": "Show old staff" );
351 this.searchBox = new Roo.form.TextField({
355 specialkey : function(f,e)
358 if (e.getKey() == 13) {
368 var dg = _this.dialog();
372 cls: 'x-btn-text-icon',
373 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
374 hidden : !dg || (_this.newDefaults() === false) || !Pman.hasPerm(this.permName, 'A'),
375 handler : function(){
376 dg.show( _this.newDefaults(), refreshPager );
379 { ///... for contacts stuff...
381 cls: 'x-btn-text-icon',
382 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
383 hidden : !this.bulkAdd() || !Pman.hasPerm(this.permName, 'A'),
384 handler : function(){
386 // Pman.Dialog.PersonBulkAdd.show( { id : 0 }, refreshPager );
387 _this.bulkAdd().show( { id : 0 }, refreshPager );
393 cls: 'x-btn-text-icon',
394 icon: Roo.rootURL + 'images/default/tree/leaf.gif',
395 hidden : !dg || !Pman.hasPerm(this.permName, 'E'),
396 handler : function(){
397 var s = grid.getSelectionModel().getSelections();
398 if (!s.length || (s.length > 1)) {
399 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
402 dg.show( s[0].data,refreshPager);
406 text: "Toogle Active",
407 cls: 'x-btn-text-icon',
408 icon: rootURL + '/Pman/templates/images/trash.gif',
409 hidden : (this.permName != 'Core.Staff') || !Pman.hasPerm(this.permName, 'E'), // SPECIFIC TO STAFF!!!!!!
410 handler : function(){
412 var s = grid.getSelectionModel().getSelections();
414 Roo.MessageBox.alert("Error", "Select People Row");
418 for(var i = 0; i < s.length; i++) {
419 r.push(s[i].data.id);
424 grid.getView().mainWrap.mask("Sending");
428 url: baseURL + '/Roo/Person.html',
431 _toggleActive : r.join(',')
433 success: function(resp) {
434 var res = Pman.processResponse(resp);
435 grid.getView().mainWrap.unmask();
437 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
443 failure: function(act) {
444 grid.getView().mainWrap.unmask();
445 Roo.MessageBox.alert("Error", "Error Sending");
455 cls: 'x-btn-text-icon',
456 hidden : !Pman.hasPerm(_this.permName, 'D'),
457 icon: rootURL + '/Pman/templates/images/trash.gif',
458 handler : function(){
459 Pman.genericDelete(_this, 'Person');
472 icon: rootURL + '/Pman/templates/images/search.gif', // icons can also be specified inline
475 handler : function () {
476 _this.grid.getSelectionModel().clearSelections();
484 icon: rootURL + '/Pman/templates/images/edit-clear.gif', // icons can also be specified inline
486 qtip: "Reset Search",
487 handler : function () {
488 _this.searchBox.setValue('');
489 _this.grid.getSelectionModel().clearSelections();
500 text: "Switch to Selected User",
501 hidden : _this.permName != 'Core.Staff' || !Pman.hasPerm('Core.Staff', 'E'),
503 click : function () {
504 var s = grid.getSelectionModel().getSelections();
506 Roo.MessageBox.alert("Error", "Select a Person");
510 url : baseURL+ '/Login.php',
512 'switch' : s[0].data.id
516 success : function() {
517 document.location = baseURL + '?ts=' + Math.random();
520 failure : function(d) {
522 Roo.MessageBox.alert("Error", d);
538 // add stuff to toolbar?
539 //this.innerLayout.endUpdate();
540 this.layout.endUpdate();
546 show: function (parentLayout, region)
548 this.add(parentLayout, region);
549 this.grid.getDataSource().load({
559 c_project_id_code : function(cfg) {
563 dataIndex : 'project_id_code',
566 renderer : function(v,x,r) {
567 return String.format('<span qtip="{0}">{1}</span>',
577 c_name : function(cfg) {
580 // id : (this.id + '-name').toLowerCase(),
584 renderer : function(v,p,r) {
585 if(r.data.active != 1){
586 return String.format('<div style="text-decoration:line-through">{0}</div>', v);
588 return String.format('{0}', v);
593 c_company_id_comptype : function(cfg) {
596 header : "Company Type",
597 dataIndex : 'company_id_comptype',
603 c_company_id_name : function(cfg) {
606 header : "Company / Office",
607 dataIndex : 'company_id_name',
610 renderer: function(v,x,r) {
611 return String.format('{0}{1}{2}',
613 r.data.office_id ? ' / ' : '',
614 r.data.office_id_name);
620 c_office_id_name : function(cfg) {
623 header : "Office / Dept.",
624 dataIndex : 'office_id_name',
630 c_role : function(cfg) {
633 header : "Role / Position",
640 c_phone : function(cfg) {
650 c_fax : function(cfg) {
660 c_email : function(cfg) {
667 renderer : function (v) {
668 return (v.length && v.indexOf('@') > 0 ) ?
669 String.format('<a href="mailto:{0}">{0}</a>',v) : v;
674 c_active : function(cfg) {
678 dataIndex : 'active',
681 renderer : function(v) {
682 // work out what the column is..
684 var state = v> 0 ? '-checked' : '';
686 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
698 // need two version of this
699 // (one can be used as edit + ProjectDirectory ADD)
700 // - the other one needs selection combos's for company / office