1 //<script type="text/javascript">
5 * >>> Pman.layout.getRegion('center').tabs.stripWrap
7 * var tbh = Pman.layout.getRegion('center').tabs.stripWrap.child('div').createChild(
9 * {tag: 'div', style: 'display:block;position:absolute;top:2;left:300;width:100%;height:25px'});
13 * - gtranslate moved to Pman.GoogleTranslate
18 if (typeof(_T) == 'undefined') { _T={};}
24 Pman = new Roo.Document(
26 /// appVersion: '1.7', // fixme = needs to be removed - use Global AppVersion
29 rightNames: { }, /// register right names here - so they can be translated and rendered.
31 * @property {Roo.menu.Menu} pulldownMenu - the 'add menu pulldown, you can use it to add items..
37 buildCompleted : false, // flag to say if we are building interface..
39 'beforeload' : true, // fired after page ready, before module building.
40 'load' : true, // fired after module building
41 'authrefreshed' : true // fire on auth updated?? - should be on Login?!?!?
47 // kludge to fix firebug debugger
48 if (typeof(console) == 'undefined') {
49 console = { log : function() { } };
53 if (Roo.get('loading')) {
54 Roo.get('loading').remove();
57 Roo.state.Manager.setProvider(new Roo.state.CookieProvider());
61 if (AppLinkError.length) {
62 Roo.MessageBox.alert("Error", AppLinkError, function() {
70 if (showNewPass.length) {
71 Pman.PasswordChange.show( { passwordReset : showNewPass },
73 // fail and success we do a load...
85 if (Roo.get('loading-logo-tile')) {
86 Roo.get('loading-logo-tile').remove();
88 if (Roo.get('loading-logo-tile-top')) {
89 Roo.get('loading-logo-tile-top').remove();
91 if (Roo.get('loading-logo-bottom')) {
92 Roo.get('loading-logo-bottom').remove();
94 if (Roo.get('loading-logo-center')) {
95 Roo.get('loading-logo-center').remove();
106 //this.fireEvent('beforeload',this);
111 return; // already loaded
113 if (Roo.get('loading')) {
114 Roo.get('loading').remove();
116 if (Roo.get('loading-mask')) {
117 Roo.get('loading-mask').show();
124 Roo.MessageBox.show({
125 title: "Please wait...",
126 msg: "Building Interface...",
133 //Pman.onLoadBuild();
134 //Roo.get(document.body).mask("Building Interface");
135 //Pman.onLoadBuild.defer(100, Pman);
136 //Pman.onLoadBuild();
139 //onLoadBuild : function() {
142 this.stime = new Date();
143 this.layout = new Roo.BorderLayout(document.body, {
157 alwaysShowTabs: true,
170 this.fireEvent('beforeload',this);
174 this.layout.beginUpdate();
175 this.layout.add('north', new Roo.ContentPanel('title', 'North'));
176 var au = Pman.Login.authUser;
177 if (au.id > 0 && au.company_id_background_color && au.company_id_background_color.length) {
178 Roo.get('title').dom.style.backgroundColor = '#' + au.company_id_background_color;
179 Roo.get('headerInformation').dom.style.color = this.invertColor('#' + au.company_id_background_color);
181 if (au.id > 0 && au.company_id_logo_id * 1 > 0) {
182 Roo.get('headerInformation-company-logo').dom.src = baseURL +
183 '/Images/' + au.company_id_logo_id + '/' + au.company_id_logo_id_filename;
185 Roo.get('headerInformation-company-logo').dom.src = Roo.BLANK_IMAGE_URL;
188 Roo.get('headerInformation').dom.innerHTML = String.format(
189 "You are Logged in as <b>{0} ({1})</b>", // to {4} v{3}", // for <b>{2}</b>",
190 au.name, au.email, au.company_id_name,
191 AppVersion , appNameShort
195 document.title = appName + ' v' + AppVersion + ' - ' + au.company_id_name;
196 Roo.QuickTips.init();
201 //this.mainLayout.beginUpdate();
202 //var maskDom = Roo.get(document.body)._maskMsg.dom
203 this.layout.beginUpdate();
205 Pman.building = true;
207 this.buildModules(this,
210 _this.layout.getRegion('center').showPanel(0);
211 _this.layout.endUpdate();
212 _this.addTopToolbar();
214 _this.fireEvent('load',this);
216 if (!_this.layout.getRegion('south').panels.length) {
217 _this.layout.getRegion('south').hide();
228 addTopToolbar : function()
230 //console.log( "t6:" + ((new Date())-stime));
231 //this.mainLayout.endUpdate();
232 // make a new tab to hold administration stuff...
235 //console.log( "t7:" + ((new Date())-stime));
236 var se = Pman.layout.getRegion('center').tabs.stripEl;
237 var tbh = se.createChild(
238 { tag: 'td', style: 'width:100%;' });
240 var lotb = new Roo.Toolbar(tbh);
243 var tbl = se.child('table', true);
244 tbl.setAttribute('width', '100%');
247 new Roo.Toolbar.Fill(),
250 text: "Change Password",
251 cls: 'x-btn-text-icon',
252 icon: rootURL + '/Pman/templates/images/change-password.gif',
253 handler : function(){
254 Pman.PasswordChange.show({});
260 if (this.topMenuItems.length) {
262 Roo.each(this.topMenuItems, function (mi) {
270 if (this.subMenuItems.length) {
272 this.subMenuItems.sort(function (a,b) {
273 return a.seqid > b.seqid ? 1 : -1;
275 // chop off last seperator.
276 // since we always add it.. just chop of last item
277 this.subMenuItems.pop();
279 var btn = new Roo.Toolbar.Button(
281 text: "Add New Item",
282 cls: 'x-btn-text-icon',
283 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
285 items : this.subMenuItems
289 this.pulldownMenu = btn.menu;
297 cls: 'x-btn-text-icon',
298 icon: rootURL + '/Pman/templates/images/logout.gif',
299 handler: function() {
306 // this.layout.endUpdate();
310 finalize : function() {
314 window.onbeforeunload = function(e) {
315 e = e || window.event;
316 var r = "Closing this window will loose changes, are you sure you want to do that?";
318 // For IE and Firefox
328 Roo.MessageBox.hide();
329 if (Roo.get('loading-mask')) {
330 Roo.get('loading-mask').remove();
334 this.buildCompleted = true; // now we can force refreshes on everything..
337 // does the URL indicate we want to see a system..
338 if (AppTrackOnLoad * 1 > 0) {
339 this.onLoadTrack(AppTrackOnLoad,false);
344 var forceAdmin = function(data)
346 if (!data || !data.id) {
347 //Roo.log("Force Admin");
348 Pman.Dialog.PersonStaff.show(
351 company_id : Pman.Login.authUser.company_id_id * 1,
352 company_id_name : Pman.Login.authUser.company_id_name
359 Roo.state.Manager.set('Pman.Login.username', data.email),
360 window.onbeforeunload = false;
361 document.location = baseURL + '?ts=' + Math.random();
364 var forceCompany = function(data) {
365 if (Pman.Login.authUser.company_id * 1 > 0) {
369 if (!data || !data.id) {
370 Pman.Dialog.Companies.show( { id : 0, isOwner : 1, comptype: 'OWNER' }, function(data) {
375 Pman.Login.authUser.company_id_id = data.id;
376 Pman.Login.authUser.company_id = data.id;
377 Pman.Login.authUser.company_id_name = data.name;
381 if (Pman.Login.authUser.id < 0) {
382 // admin company has been created - create the user..
383 if (Pman.Login.authUser.company_id_id* 1 > 0) {
401 onLoadTrack : function(id,cb) {
402 this.onLoadTrackCall(id, cb, 'DocumentsCirc_');
404 onLoadTrackEdit : function(id,cb) {
405 this.onLoadTrackCall(id, cb, 'Documents_');
409 /// ----------- FIXME -----
412 onLoadTrackCall : function(id,cb, cls) {
413 Roo.get(document.body).mask("Loading Document details");
416 url: baseURL + '/Roo/Documents.html',
421 success : function(data) {
422 Roo.get(document.body).unmask();
425 switch(data.in_out) {
426 case 'IN' : cls+='In';break;
427 case 'OUT' : cls+='Out';break;
428 case 'WIP' : cls+='Wip';break;
430 Roo.MessageBox.alert("Error", "invalid in_out");
433 Pman.Dialog[cls].show(data, cb ? cb : Pman.refreshActivePanel);
436 failure: function() {
437 Roo.get(document.body).unmask();
447 refreshActivePanel : function() {
448 var actpan = this.layout.getRegion('center').getActivePanel();
449 if (actpan.controller && actpan.controller.paging) {
450 actpan.controller.paging.onClick('refresh');
454 var agid = Pman.layout.getRegion('center').getActivePanel().id;
458 Pman.Tab[agid].paging.onClick('refresh');
460 toCidV : function(data) {
461 return 'C' + data.in_out.substring(0,1) + data.cid;
466 * eg. has Pman.hasPerm('Admin.Admin_Tab', 'S') == showlist..
469 hasPerm: function(name, lvl) {
471 (typeof(Pman.Login.authUser) != 'object')
473 (typeof(Pman.Login.authUser.perms) != 'object')
475 (typeof(Pman.Login.authUser.perms[name]) != 'string')
480 return Pman.Login.authUser.perms[name].indexOf(lvl) > -1;
497 processResponse : function (response)
501 res = Roo.decode(response.responseText);
503 if (typeof(res) != 'object') {
504 res = { success : false, errorMsg : res, errors : true };
506 if (typeof(res.success) == 'undefined') {
511 res = { success : false, errorMsg : response.responseText, errors : true };
515 genericDelete : function(tab,tbl) {
520 var s = tab.grid.getSelectionModel().getSelections();
522 Roo.MessageBox.alert("Error", "Select at least one Row to delete" );
526 for(var i = 0; i < s.length; i++) {
527 r.push(s[i].data.id);
530 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
535 // what about the toolbar??
536 tab.grid.getView().mainWrap.mask("Deleting");
538 url: baseURL + '/Roo/'+tbl+'.php',
541 _delete : r.join(',')
543 success: function(response) {
544 tab.grid.getView().mainWrap.unmask();
546 tab.paging.onClick('refresh');
547 } else if (tab.refresh) {
549 } else if (tab.grid.footer && tab.grid.footer.onClick) {
550 // new xtype built grids
551 tab.grid.footer.onClick('refresh');
553 tab.grid.getDataSource().load();
559 failure: function(act) {
560 tab.grid.getView().mainWrap.unmask();
561 Roo.MessageBox.alert("Error", "Error Deleting");
572 standardActionFailed : function(f, act, cb) {
574 if (act.failureType == 'client') {
575 Roo.MessageBox.alert("Error", "Please Correct all the errors in red", cb);
578 if (act.failureType == 'connect') {
579 Roo.MessageBox.alert("Error", "Problem Connecting to Server - please try again.", cb);
583 if (act.type == 'submit') {
585 Roo.MessageBox.alert("Error", typeof(act.result.errorMsg) == 'string' ?
586 String.format('{0}', act.result.errorMsg) :
587 "Saving failed = fix errors and try again", cb);
591 // what about load failing..
592 Roo.MessageBox.alert("Error", "Error loading details",cb);
595 * Depreciated - USE new Pman.Request
599 request : function(c) {
600 var r= new Roo.data.Connection({
601 timeout : typeof(c.timeout) == 'undefined' ? 30000 : c.timeout
608 success: function(response, opts) { // check successfull...
610 var res = Pman.processResponse(response);
612 if (!res.success) { // error!
614 if (true === c.failure.call(this,response, opts)) {
618 Roo.MessageBox.hide();
619 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
623 c.success.call(this, res.data);
627 failure : function(response, opts) { // check successfull...
630 if (true === c.failure.call(this,response, opts)) {
634 Roo.MessageBox.hide();
635 Roo.MessageBox.alert("Error", "Connection timed out sending");
645 // depreciated - use Pman.Download()
647 download : function(c) {
649 return new Pman.Download(c);
652 // fixme - move to document manager...
653 downloadRevision : function(doc, rev)
656 url: baseURL + '/Documents/Doc/DownloadRev/'+ doc.id + '/' + rev + '/' +
657 doc.project_id_code + '-' + doc.cidV + '-' + rev + '-' + doc.filename
663 exportCSV : function(c) {
665 for(var i=0;i < c.csvFormat.length;i++) {
666 c.params['csvCols['+i+']'] = c.csvFormat[i][0];
667 c.params['csvTitles['+i+']'] = c.csvFormat[i][1];
669 c.url += '?' + Roo.urlEncode(c.params);
675 prettyDate : function (value)
677 if (typeof(value) == 'string') {
678 var ds = Date.parseDate(value, 'Y-m-d H:i:s');
680 return this.prettyDate(ds);
682 ds = Date.parseDate(value, 'Y-m-d');
684 return this.prettyDate(ds);
693 var daysSince = Math.floor(td.getElapsed(value) / (1000 * 60*60*24));
695 return value.dateFormat('D H:i');
699 if (td.dateFormat('m') == value.dateFormat('m')) {
700 return value.dateFormat('dS D');
703 if (td.dateFormat('Y') == value.dateFormat('Y')) {
704 return value.dateFormat('dS M');
706 return value.dateFormat('d M Y');
708 loadException : function(a,b,c,d)
710 if (d && d.authFailure) {
714 Roo.MessageBox.alert("Problem Loading Data", a.message || c.statusText);
720 * Routine to flash alerts in the title bar..
725 notifyActive : false,
727 notifyTitle: function(msg)
729 if (this.notifyActive ) {
734 var stopper = function() {
736 document.title = oldtitle;
739 Roo.get(document.body).on('mousemove', stopper, this);
740 var oldtitle = document.title;
743 var ivl = window.setInterval(function() {
746 Roo.get(document.body).un('mousemove', stopper, this);
747 _this.notifyActive = false;
748 document.title = oldtitle;
749 window.clearInterval(ivl);
753 document.title = s ? msg : oldtitle;
755 }, 1000); // every 120 secs = 2mins..
756 document.title = msg;
767 modKey : '00-admin-xxxx',
768 module : Pman.Tab.projectMgr,
769 moduleName : 'Pman.Tab.projectMgr',
775 register : function(obj)
778 // ignore registration of objects which are disabled.
779 appDisabled = typeof(appDisabled) == 'undefined' ? [] : appDisabled;
781 if ((typeof(obj.moduleName) != 'undefined')
782 && APPDISABLED.indexOf(obj.moduleName) > -1)
788 if (obj.parent === false) {
789 //console.log('skip module (no parent)' + obj.modkey);
792 // this is an error condition - the parent does not exist..
793 // technically it should not happen..
794 console.log("Parent is missing");
798 if (!obj.parent.modules) {
799 obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.modKey });
802 obj.parent.modules.add(obj);
806 buildModules : function(parent, onComplete)
810 var cmp = function(a,b) {
811 return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
814 if (!parent.modules) {
817 parent.modules.keySort('ASC', cmp );
821 // add modules to their parents..
822 var addMod = function(m) {
823 // console.log(m.modKey);
826 if (m.module.modules) {
827 m.module.modules.keySort('ASC', cmp );
828 m.module.modules.each(addMod);
831 m.finalize.name = m.name + " (clean up) ";
832 mods.push(m.finalize);
837 parent.modules.each(addMod);
838 //this.allmods = mods;
842 if (onComplete) onComplete();
845 // flash it up as modal - so we store the mask!?
846 Roo.MessageBox.show({ title: 'loading' });
847 Roo.MessageBox.show({
848 title: "Please wait...",
849 msg: "Building Interface...",
857 var progressRun = function() {
862 Roo.MessageBox.updateProgress(
863 (n+1)/mods.length, "Building Interface " + (n+1) +
864 " of " + mods.length +
865 (mod.name ? (' - ' + mod.name) : '')
870 if (typeof(mod) == 'function') {
873 } else if (mod.parent.layout && !mod.module.disabled) {
874 // honour permname setings..
875 if (mod.permname && mod.permname.length) {
876 if (Pman.hasPerm(mod.permname, 'S')) {
877 mod.module.add(mod.parent.layout, mod.region);
880 mod.module.add(mod.parent.layout, mod.region);
888 if (n >= mods.length) {
894 progressRun.defer(10, Pman);
896 progressRun.defer(1, Pman);
902 invertColor : function(c)
906 for(var i = 0; i < 3; i++){
907 ca[i] = parseInt(c.charAt((i*2)+1) + c.charAt((i*2)+2), 16);
912 Roo.each(ca, function(hi) {
913 var h = parseInt(255-hi).toString(16);