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={};}
22 Roo.XComponent.on('register', function(e) { return Pman.xregister(e); });
23 Roo.XComponent.on('buildComplete',
26 Pman.layout.getRegion('center').showPanel(0);
27 Pman.layout.endUpdate();
30 Pman.fireEvent('load',this);
32 if (!Pman.layout.getRegion('south').panels.length) {
33 Pman.layout.getRegion('south').hide();
42 Pman = new Roo.Document(
44 /// appVersion: '1.7', // fixme = needs to be removed - use Global AppVersion
47 rightNames: { }, /// register right names here - so they can be translated and rendered.
49 * @property {Roo.menu.Menu} pulldownMenu - the 'add menu pulldown, you can use it to add items..
55 buildCompleted : false, // flag to say if we are building interface..
57 'beforeload' : true, // fired after page ready, before module building.
58 'load' : true, // fired after module building
59 'authrefreshed' : true // fire on auth updated?? - should be on Login?!?!?
65 // kludge to fix firebug debugger
66 if (typeof(console) == 'undefined') {
67 console = { log : function() { } };
71 if (Roo.get('loading')) {
72 Roo.get('loading').remove();
75 Roo.state.Manager.setProvider(new Roo.state.CookieProvider());
79 if (AppLinkError.length) {
80 Roo.MessageBox.alert("Error", AppLinkError, function() {
88 if (showNewPass.length) {
89 Pman.PasswordChange.show( { passwordReset : showNewPass },
91 // fail and success we do a load...
103 if (Roo.get('loading-logo-tile')) {
104 Roo.get('loading-logo-tile').remove();
106 if (Roo.get('loading-logo-tile-top')) {
107 Roo.get('loading-logo-tile-top').remove();
109 if (Roo.get('loading-logo-bottom')) {
110 Roo.get('loading-logo-bottom').remove();
112 if (Roo.get('loading-logo-center')) {
113 Roo.get('loading-logo-center').remove();
119 fakeRoot : new XComponent( {
133 //this.fireEvent('beforeload',this);
138 return; // already loaded
140 if (Roo.get('loading')) {
141 Roo.get('loading').remove();
143 if (Roo.get('loading-mask')) {
144 Roo.get('loading-mask').show();
149 this.stime = new Date();
150 this.layout = new Roo.BorderLayout(document.body, {
164 alwaysShowTabs: true,
176 this.fakeRoot.layout = this.layout;
178 Pman.register( Roo.apply(this.fakeRoot, {
185 // creates all the modules ready to load..
187 this.fireEvent('beforeload',this);
191 this.layout.beginUpdate();
192 this.layout.add('north', new Roo.ContentPanel('title', 'North'));
193 var au = Pman.Login.authUser;
194 if (au.id > 0 && au.company_id_background_color && au.company_id_background_color.length) {
195 Roo.get('title').dom.style.backgroundColor = '#' + au.company_id_background_color;
196 Roo.get('headerInformation').dom.style.color = this.invertColor('#' + au.company_id_background_color);
198 if (au.id > 0 && au.company_id_logo_id * 1 > 0) {
199 Roo.get('headerInformation-company-logo').dom.src = baseURL +
200 '/Images/' + au.company_id_logo_id + '/' + au.company_id_logo_id_filename;
202 Roo.get('headerInformation-company-logo').dom.src = Roo.BLANK_IMAGE_URL;
205 Roo.get('headerInformation').dom.innerHTML = String.format(
206 "You are Logged in as <b>{0} ({1})</b>", // to {4} v{3}", // for <b>{2}</b>",
207 au.name, au.email, au.company_id_name,
208 AppVersion , appNameShort
212 document.title = appName + ' v' + AppVersion + ' - ' + au.company_id_name;
213 Roo.QuickTips.init();
218 //this.mainLayout.beginUpdate();
219 //var maskDom = Roo.get(document.body)._maskMsg.dom
220 this.layout.beginUpdate();
222 Pman.building = true;
223 Roo.XComponent.build();
230 addTopToolbar : function()
232 //console.log( "t6:" + ((new Date())-stime));
233 //this.mainLayout.endUpdate();
234 // make a new tab to hold administration stuff...
237 //console.log( "t7:" + ((new Date())-stime));
238 var se = Pman.layout.getRegion('center').tabs.stripEl;
239 var tbh = se.createChild(
240 { tag: 'td', style: 'width:100%;' });
242 var lotb = new Roo.Toolbar(tbh);
245 var tbl = se.child('table', true);
246 tbl.setAttribute('width', '100%');
249 new Roo.Toolbar.Fill(),
252 text: "Change Password",
253 cls: 'x-btn-text-icon',
254 icon: rootURL + '/Pman/templates/images/change-password.gif',
255 handler : function(){
256 Pman.PasswordChange.show({});
262 if (this.topMenuItems.length) {
264 Roo.each(this.topMenuItems, function (mi) {
272 if (this.subMenuItems.length) {
274 this.subMenuItems.sort(function (a,b) {
275 return a.seqid > b.seqid ? 1 : -1;
277 // chop off last seperator.
278 // since we always add it.. just chop of last item
279 this.subMenuItems.pop();
281 var btn = new Roo.Toolbar.Button(
283 text: "Add New Item",
284 cls: 'x-btn-text-icon',
285 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
287 items : this.subMenuItems
291 this.pulldownMenu = btn.menu;
299 cls: 'x-btn-text-icon',
300 icon: rootURL + '/Pman/templates/images/logout.gif',
301 handler: function() {
308 // this.layout.endUpdate();
312 finalize : function() {
316 window.onbeforeunload = function(e) {
317 e = e || window.event;
318 var r = "Closing this window will loose changes, are you sure you want to do that?";
320 // For IE and Firefox
330 Roo.MessageBox.hide();
331 if (Roo.get('loading-mask')) {
332 Roo.get('loading-mask').remove();
336 this.buildCompleted = true; // now we can force refreshes on everything..
339 // does the URL indicate we want to see a system..
340 if (AppTrackOnLoad * 1 > 0) {
341 this.onLoadTrack(AppTrackOnLoad,false);
346 var forceAdmin = function(data)
348 if (!data || !data.id) {
349 //Roo.log("Force Admin");
350 Pman.Dialog.PersonStaff.show(
353 company_id : Pman.Login.authUser.company_id_id * 1,
354 company_id_name : Pman.Login.authUser.company_id_name
361 Roo.state.Manager.set('Pman.Login.username', data.email),
362 window.onbeforeunload = false;
363 document.location = baseURL + '?ts=' + Math.random();
366 var forceCompany = function(data) {
367 if (Pman.Login.authUser.company_id * 1 > 0) {
371 if (!data || !data.id) {
372 Pman.Dialog.Companies.show( { id : 0, isOwner : 1, comptype: 'OWNER' }, function(data) {
377 Pman.Login.authUser.company_id_id = data.id;
378 Pman.Login.authUser.company_id = data.id;
379 Pman.Login.authUser.company_id_name = data.name;
383 if (Pman.Login.authUser.id < 0) {
384 // admin company has been created - create the user..
385 if (Pman.Login.authUser.company_id_id* 1 > 0) {
403 onLoadTrack : function(id,cb) {
404 this.onLoadTrackCall(id, cb, 'DocumentsCirc_');
406 onLoadTrackEdit : function(id,cb) {
407 this.onLoadTrackCall(id, cb, 'Documents_');
411 /// ----------- FIXME -----
414 onLoadTrackCall : function(id,cb, cls) {
415 Roo.get(document.body).mask("Loading Document details");
418 url: baseURL + '/Roo/Documents.html',
423 success : function(data) {
424 Roo.get(document.body).unmask();
427 switch(data.in_out) {
428 case 'IN' : cls+='In';break;
429 case 'OUT' : cls+='Out';break;
430 case 'WIP' : cls+='Wip';break;
432 Roo.MessageBox.alert("Error", "invalid in_out");
435 Pman.Dialog[cls].show(data, cb ? cb : Pman.refreshActivePanel);
438 failure: function() {
439 Roo.get(document.body).unmask();
449 refreshActivePanel : function() {
450 var actpan = this.layout.getRegion('center').getActivePanel();
451 if (actpan.controller && actpan.controller.paging) {
452 actpan.controller.paging.onClick('refresh');
456 var agid = Pman.layout.getRegion('center').getActivePanel().id;
460 Pman.Tab[agid].paging.onClick('refresh');
462 toCidV : function(data) {
463 return 'C' + data.in_out.substring(0,1) + data.cid;
469 * Does the authenticated user have permission to see this.
471 * @param {String} name the [Module].[permission] to check for
472 * @param {Char} lvl - which type of permission to use (eg. S=show...)
473 * @returns {Boolean} tue indicates permission allowed
475 hasPerm: function(name, lvl) {
477 (typeof(Pman.Login.authUser) != 'object')
479 (typeof(Pman.Login.authUser.perms) != 'object')
481 (typeof(Pman.Login.authUser.perms[name]) != 'string')
486 return Pman.Login.authUser.perms[name].indexOf(lvl) > -1;
491 * Is there a permission defined for this (used by module registration.)
493 * @param {String} name the [Module].[permission] to check for
494 * @returns {Boolean} tue indicates permission exists.
496 hasPermExists: function(name) {
498 (typeof(Pman.Login.authUser) != 'object')
500 (typeof(Pman.Login.authUser.perms) != 'object')
502 (typeof(Pman.Login.authUser.perms[name]) != 'string')
520 processResponse : function (response)
524 res = Roo.decode(response.responseText);
526 if (typeof(res) != 'object') {
527 res = { success : false, errorMsg : res, errors : true };
529 if (typeof(res.success) == 'undefined') {
534 res = { success : false, errorMsg : response.responseText, errors : true };
538 genericDelete : function(tab,tbl) {
543 var s = tab.grid.getSelectionModel().getSelections();
545 Roo.MessageBox.alert("Error", "Select at least one Row to delete" );
549 for(var i = 0; i < s.length; i++) {
550 r.push(s[i].data.id);
553 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
558 // what about the toolbar??
559 tab.grid.getView().mainWrap.mask("Deleting");
561 url: baseURL + '/Roo/'+tbl+'.php',
564 _delete : r.join(',')
566 success: function(response) {
567 tab.grid.getView().mainWrap.unmask();
569 tab.paging.onClick('refresh');
570 } else if (tab.refresh) {
572 } else if (tab.grid.footer && tab.grid.footer.onClick) {
573 // new xtype built grids
574 tab.grid.footer.onClick('refresh');
576 tab.grid.getDataSource().load();
582 failure: function(act) {
583 tab.grid.getView().mainWrap.unmask();
584 Roo.MessageBox.alert("Error", "Error Deleting");
595 standardActionFailed : function(f, act, cb) {
597 if (act.failureType == 'client') {
598 Roo.MessageBox.alert("Error", "Please Correct all the errors in red", cb);
601 if (act.failureType == 'connect') {
602 Roo.MessageBox.alert("Error", "Problem Connecting to Server - please try again.", cb);
606 if (act.type == 'submit') {
608 Roo.MessageBox.alert("Error", typeof(act.result.errorMsg) == 'string' ?
609 String.format('{0}', act.result.errorMsg) :
610 "Saving failed = fix errors and try again", cb);
614 // what about load failing..
615 Roo.MessageBox.alert("Error", "Error loading details",cb);
618 * Depreciated - USE new Pman.Request
622 request : function(c) {
623 var r= new Roo.data.Connection({
624 timeout : typeof(c.timeout) == 'undefined' ? 30000 : c.timeout
631 success: function(response, opts) { // check successfull...
633 var res = Pman.processResponse(response);
635 if (!res.success) { // error!
637 if (true === c.failure.call(this,response, opts)) {
641 Roo.MessageBox.hide();
642 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
646 c.success.call(this, res.data);
650 failure : function(response, opts) { // check successfull...
653 if (true === c.failure.call(this,response, opts)) {
657 Roo.MessageBox.hide();
658 Roo.MessageBox.alert("Error", "Connection timed out sending");
668 // depreciated - use Pman.Download()
670 download : function(c) {
672 return new Pman.Download(c);
675 // fixme - move to document manager...
676 downloadRevision : function(doc, rev)
679 url: baseURL + '/Documents/Doc/DownloadRev/'+ doc.id + '/' + rev + '/' +
680 doc.project_id_code + '-' + doc.cidV + '-' + rev + '-' + doc.filename
686 exportCSV : function(c) {
688 for(var i=0;i < c.csvFormat.length;i++) {
689 c.params['csvCols['+i+']'] = c.csvFormat[i][0];
690 c.params['csvTitles['+i+']'] = c.csvFormat[i][1];
692 c.url += '?' + Roo.urlEncode(c.params);
698 prettyDate : function (value)
700 if (typeof(value) == 'string') {
701 var ds = Date.parseDate(value, 'Y-m-d H:i:s');
703 return this.prettyDate(ds);
705 ds = Date.parseDate(value, 'Y-m-d');
707 return this.prettyDate(ds);
716 var daysSince = Math.floor(td.getElapsed(value) / (1000 * 60*60*24));
718 return value.dateFormat('D H:i');
722 if (td.dateFormat('m') == value.dateFormat('m')) {
723 return value.dateFormat('dS D');
726 if (td.dateFormat('Y') == value.dateFormat('Y')) {
727 return value.dateFormat('dS M');
729 return value.dateFormat('d M Y');
731 loadException : function(a,b,c,d)
733 if (d && d.authFailure) {
737 Roo.MessageBox.alert("Problem Loading Data", a.message || c.statusText);
743 * Routine to flash alerts in the title bar..
748 notifyActive : false,
750 notifyTitle: function(msg)
752 if (this.notifyActive ) {
757 var stopper = function() {
759 document.title = oldtitle;
762 Roo.get(document.body).on('mousemove', stopper, this);
763 var oldtitle = document.title;
766 var ivl = window.setInterval(function() {
769 Roo.get(document.body).un('mousemove', stopper, this);
770 _this.notifyActive = false;
771 document.title = oldtitle;
772 window.clearInterval(ivl);
776 document.title = s ? msg : oldtitle;
778 }, 1000); // every 120 secs = 2mins..
779 document.title = msg;
785 * @property {Array} appModules - array based on AppModules global
792 xregister : function(obj)
796 if (!this.appModules === false) {
797 this.appModules = typeof(AppModules ) == 'undefined'? [] :
798 AppModules.split(',');
803 // ignore registration of objects which are disabled.
804 // global supplied by master.html
805 appDisabled = typeof(appDisabled) == 'undefined' ? [] : appDisabled;
809 // previously we did not a good naming policy for module and parts
810 // most things that are called module here, really are 'parts'
811 // new versions should have 'part' as [ module : part ]
814 if (typeof(obj.part) != 'undefined') {
816 var permname = obj.part.join('.');
817 // we now have permission...
818 // obj.moduleOwner '.' lname
820 if (this.hasPermExists(permname) && !this.hasPerm(permname,'S')) {
821 // it's a turned off permission...
822 Roo.log(permname + " is Disabled for this user");
826 if (appDisabled.indexOf(permname) > -1) {
827 Roo.log(permname + " is Disabled for this site");
836 // false parent... use it..
841 if (obj.parent === Pman || obj.parent == 'Pman') {
842 Roo.log("PARENT OF : " + obj.name + " replacing with fake");
843 obj.parent = Pman.fakeRoot;
846 if (typeof(obj.parent) == 'undefined') {
847 console.log("Parent is undefined");
854 if (obj.parent === false) {
856 console.log('ignoring top level object (as parent===false found)');
860 // this is an error condition - the parent does not exist..
861 // technically it should not happen..
863 // hack for Pman parent == Pman..
864 if (obj.parent == obj.module) {
872 * DEPRICATED : use Roo.XComponents now..
875 modKey : '00-admin-xxxx',
876 module : Pman.Tab.projectMgr, << really a components..
877 part : [ 'Admin', 'ProjectManager' ]
884 register : function(obj)
887 //this.xregister(obj);
890 // old style calls go in here..
891 // we need to convert the object so that it looks a bit like an XCompoenent..
893 obj.render = function()
896 Roo.log("Skip module, as parent does not exist");
900 //if (typeof(mod) == 'function') {
903 if (typeof(this.region) == 'undefined') {
904 Roo.log("Module does not have region defined, skipping");
908 if (this.module.disabled) {
909 Roo.log("Module disabled, should not rendering")
914 if (!this.parent.layout) {
915 Roo.log("Module parent does not have property layout.")
920 // honour DEPRICATED permname setings..
921 // new code should use PART name, and matching permissions.
922 if (this.permname && this.permname.length) {
923 if (!Pman.hasPerm(this.permname, 'S')) {
928 this.add(this.parent.layout, this.region);
929 this.el = this.layout;
934 // map some of the standard properties..
935 obj.order = obj.modKey;
941 // the other issue we have is that
944 // Roo.log("CALLING XComponent register with : " + obj.name);
946 // this will call xregister as it's the on.register handler..
947 Roo.XComponent.register(obj.isTop ? obj : Roo.apply(obj.module, obj));
950 invertColor : function(c)
954 for(var i = 0; i < 3; i++){
955 ca[i] = parseInt(c.charAt((i*2)+1) + c.charAt((i*2)+2), 16);
960 Roo.each(ca, function(hi) {
961 var h = parseInt(255-hi).toString(16);