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();
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,
178 Pman.register( Roo.apply(this.fakeRoot, {
184 // creates all the modules ready to load..
186 this.fireEvent('beforeload',this);
190 this.layout.beginUpdate();
191 this.layout.add('north', new Roo.ContentPanel('title', 'North'));
192 var au = Pman.Login.authUser;
193 if (au.id > 0 && au.company_id_background_color && au.company_id_background_color.length) {
194 Roo.get('title').dom.style.backgroundColor = '#' + au.company_id_background_color;
195 Roo.get('headerInformation').dom.style.color = this.invertColor('#' + au.company_id_background_color);
197 if (au.id > 0 && au.company_id_logo_id * 1 > 0) {
198 Roo.get('headerInformation-company-logo').dom.src = baseURL +
199 '/Images/' + au.company_id_logo_id + '/' + au.company_id_logo_id_filename;
201 Roo.get('headerInformation-company-logo').dom.src = Roo.BLANK_IMAGE_URL;
204 Roo.get('headerInformation').dom.innerHTML = String.format(
205 "You are Logged in as <b>{0} ({1})</b>", // to {4} v{3}", // for <b>{2}</b>",
206 au.name, au.email, au.company_id_name,
207 AppVersion , appNameShort
211 document.title = appName + ' v' + AppVersion + ' - ' + au.company_id_name;
212 Roo.QuickTips.init();
217 //this.mainLayout.beginUpdate();
218 //var maskDom = Roo.get(document.body)._maskMsg.dom
219 this.layout.beginUpdate();
221 Pman.building = true;
222 Roo.XComponent.build();
229 addTopToolbar : function()
231 //console.log( "t6:" + ((new Date())-stime));
232 //this.mainLayout.endUpdate();
233 // make a new tab to hold administration stuff...
236 //console.log( "t7:" + ((new Date())-stime));
237 var se = Pman.layout.getRegion('center').tabs.stripEl;
238 var tbh = se.createChild(
239 { tag: 'td', style: 'width:100%;' });
241 var lotb = new Roo.Toolbar(tbh);
244 var tbl = se.child('table', true);
245 tbl.setAttribute('width', '100%');
248 new Roo.Toolbar.Fill(),
251 text: "Change Password",
252 cls: 'x-btn-text-icon',
253 icon: rootURL + '/Pman/templates/images/change-password.gif',
254 handler : function(){
255 Pman.PasswordChange.show({});
261 if (this.topMenuItems.length) {
263 Roo.each(this.topMenuItems, function (mi) {
271 if (this.subMenuItems.length) {
273 this.subMenuItems.sort(function (a,b) {
274 return a.seqid > b.seqid ? 1 : -1;
276 // chop off last seperator.
277 // since we always add it.. just chop of last item
278 this.subMenuItems.pop();
280 var btn = new Roo.Toolbar.Button(
282 text: "Add New Item",
283 cls: 'x-btn-text-icon',
284 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
286 items : this.subMenuItems
290 this.pulldownMenu = btn.menu;
298 cls: 'x-btn-text-icon',
299 icon: rootURL + '/Pman/templates/images/logout.gif',
300 handler: function() {
307 // this.layout.endUpdate();
311 finalize : function() {
315 window.onbeforeunload = function(e) {
316 e = e || window.event;
317 var r = "Closing this window will loose changes, are you sure you want to do that?";
319 // For IE and Firefox
329 Roo.MessageBox.hide();
330 if (Roo.get('loading-mask')) {
331 Roo.get('loading-mask').remove();
335 this.buildCompleted = true; // now we can force refreshes on everything..
338 // does the URL indicate we want to see a system..
339 if (AppTrackOnLoad * 1 > 0) {
340 this.onLoadTrack(AppTrackOnLoad,false);
345 var forceAdmin = function(data)
347 if (!data || !data.id) {
348 //Roo.log("Force Admin");
349 Pman.Dialog.PersonStaff.show(
352 company_id : Pman.Login.authUser.company_id_id * 1,
353 company_id_name : Pman.Login.authUser.company_id_name
360 Roo.state.Manager.set('Pman.Login.username', data.email),
361 window.onbeforeunload = false;
362 document.location = baseURL + '?ts=' + Math.random();
365 var forceCompany = function(data) {
366 if (Pman.Login.authUser.company_id * 1 > 0) {
370 if (!data || !data.id) {
371 Pman.Dialog.Companies.show( { id : 0, isOwner : 1, comptype: 'OWNER' }, function(data) {
376 Pman.Login.authUser.company_id_id = data.id;
377 Pman.Login.authUser.company_id = data.id;
378 Pman.Login.authUser.company_id_name = data.name;
382 if (Pman.Login.authUser.id < 0) {
383 // admin company has been created - create the user..
384 if (Pman.Login.authUser.company_id_id* 1 > 0) {
402 onLoadTrack : function(id,cb) {
403 this.onLoadTrackCall(id, cb, 'DocumentsCirc_');
405 onLoadTrackEdit : function(id,cb) {
406 this.onLoadTrackCall(id, cb, 'Documents_');
410 /// ----------- FIXME -----
413 onLoadTrackCall : function(id,cb, cls) {
414 Roo.get(document.body).mask("Loading Document details");
417 url: baseURL + '/Roo/Documents.html',
422 success : function(data) {
423 Roo.get(document.body).unmask();
426 switch(data.in_out) {
427 case 'IN' : cls+='In';break;
428 case 'OUT' : cls+='Out';break;
429 case 'WIP' : cls+='Wip';break;
431 Roo.MessageBox.alert("Error", "invalid in_out");
434 Pman.Dialog[cls].show(data, cb ? cb : Pman.refreshActivePanel);
437 failure: function() {
438 Roo.get(document.body).unmask();
448 refreshActivePanel : function() {
449 var actpan = this.layout.getRegion('center').getActivePanel();
450 if (actpan.controller && actpan.controller.paging) {
451 actpan.controller.paging.onClick('refresh');
455 var agid = Pman.layout.getRegion('center').getActivePanel().id;
459 Pman.Tab[agid].paging.onClick('refresh');
461 toCidV : function(data) {
462 return 'C' + data.in_out.substring(0,1) + data.cid;
468 * Does the authenticated user have permission to see this.
470 * @param {String} name the [Module].[permission] to check for
471 * @param {Char} lvl - which type of permission to use (eg. S=show...)
472 * @returns {Boolean} tue indicates permission allowed
474 hasPerm: function(name, lvl) {
476 (typeof(Pman.Login.authUser) != 'object')
478 (typeof(Pman.Login.authUser.perms) != 'object')
480 (typeof(Pman.Login.authUser.perms[name]) != 'string')
485 return Pman.Login.authUser.perms[name].indexOf(lvl) > -1;
490 * Is there a permission defined for this (used by module registration.)
492 * @param {String} name the [Module].[permission] to check for
493 * @returns {Boolean} tue indicates permission exists.
495 hasPermExists: function(name) {
497 (typeof(Pman.Login.authUser) != 'object')
499 (typeof(Pman.Login.authUser.perms) != 'object')
501 (typeof(Pman.Login.authUser.perms[name]) != 'string')
519 processResponse : function (response)
523 res = Roo.decode(response.responseText);
525 if (typeof(res) != 'object') {
526 res = { success : false, errorMsg : res, errors : true };
528 if (typeof(res.success) == 'undefined') {
533 res = { success : false, errorMsg : response.responseText, errors : true };
537 genericDelete : function(tab,tbl) {
542 var s = tab.grid.getSelectionModel().getSelections();
544 Roo.MessageBox.alert("Error", "Select at least one Row to delete" );
548 for(var i = 0; i < s.length; i++) {
549 r.push(s[i].data.id);
552 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
557 // what about the toolbar??
558 tab.grid.getView().mainWrap.mask("Deleting");
560 url: baseURL + '/Roo/'+tbl+'.php',
563 _delete : r.join(',')
565 success: function(response) {
566 tab.grid.getView().mainWrap.unmask();
568 tab.paging.onClick('refresh');
569 } else if (tab.refresh) {
571 } else if (tab.grid.footer && tab.grid.footer.onClick) {
572 // new xtype built grids
573 tab.grid.footer.onClick('refresh');
575 tab.grid.getDataSource().load();
581 failure: function(act) {
582 tab.grid.getView().mainWrap.unmask();
583 Roo.MessageBox.alert("Error", "Error Deleting");
594 standardActionFailed : function(f, act, cb) {
596 if (act.failureType == 'client') {
597 Roo.MessageBox.alert("Error", "Please Correct all the errors in red", cb);
600 if (act.failureType == 'connect') {
601 Roo.MessageBox.alert("Error", "Problem Connecting to Server - please try again.", cb);
605 if (act.type == 'submit') {
607 Roo.MessageBox.alert("Error", typeof(act.result.errorMsg) == 'string' ?
608 String.format('{0}', act.result.errorMsg) :
609 "Saving failed = fix errors and try again", cb);
613 // what about load failing..
614 Roo.MessageBox.alert("Error", "Error loading details",cb);
617 * Depreciated - USE new Pman.Request
621 request : function(c) {
622 var r= new Roo.data.Connection({
623 timeout : typeof(c.timeout) == 'undefined' ? 30000 : c.timeout
630 success: function(response, opts) { // check successfull...
632 var res = Pman.processResponse(response);
634 if (!res.success) { // error!
636 if (true === c.failure.call(this,response, opts)) {
640 Roo.MessageBox.hide();
641 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
645 c.success.call(this, res.data);
649 failure : function(response, opts) { // check successfull...
652 if (true === c.failure.call(this,response, opts)) {
656 Roo.MessageBox.hide();
657 Roo.MessageBox.alert("Error", "Connection timed out sending");
667 // depreciated - use Pman.Download()
669 download : function(c) {
671 return new Pman.Download(c);
674 // fixme - move to document manager...
675 downloadRevision : function(doc, rev)
678 url: baseURL + '/Documents/Doc/DownloadRev/'+ doc.id + '/' + rev + '/' +
679 doc.project_id_code + '-' + doc.cidV + '-' + rev + '-' + doc.filename
685 exportCSV : function(c) {
687 for(var i=0;i < c.csvFormat.length;i++) {
688 c.params['csvCols['+i+']'] = c.csvFormat[i][0];
689 c.params['csvTitles['+i+']'] = c.csvFormat[i][1];
691 c.url += '?' + Roo.urlEncode(c.params);
697 prettyDate : function (value)
699 if (typeof(value) == 'string') {
700 var ds = Date.parseDate(value, 'Y-m-d H:i:s');
702 return this.prettyDate(ds);
704 ds = Date.parseDate(value, 'Y-m-d');
706 return this.prettyDate(ds);
715 var daysSince = Math.floor(td.getElapsed(value) / (1000 * 60*60*24));
717 return value.dateFormat('D H:i');
721 if (td.dateFormat('m') == value.dateFormat('m')) {
722 return value.dateFormat('dS D');
725 if (td.dateFormat('Y') == value.dateFormat('Y')) {
726 return value.dateFormat('dS M');
728 return value.dateFormat('d M Y');
730 loadException : function(a,b,c,d)
732 if (d && d.authFailure) {
736 Roo.MessageBox.alert("Problem Loading Data", a.message || c.statusText);
742 * Routine to flash alerts in the title bar..
747 notifyActive : false,
749 notifyTitle: function(msg)
751 if (this.notifyActive ) {
756 var stopper = function() {
758 document.title = oldtitle;
761 Roo.get(document.body).on('mousemove', stopper, this);
762 var oldtitle = document.title;
765 var ivl = window.setInterval(function() {
768 Roo.get(document.body).un('mousemove', stopper, this);
769 _this.notifyActive = false;
770 document.title = oldtitle;
771 window.clearInterval(ivl);
775 document.title = s ? msg : oldtitle;
777 }, 1000); // every 120 secs = 2mins..
778 document.title = msg;
784 * @property {Array} appModules - array based on AppModules global
791 xregister : function(obj)
795 if (!this.appModules === false) {
796 this.appModules = typeof(AppModules ) == 'undefined'? [] :
797 AppModules.split(',');
802 // ignore registration of objects which are disabled.
803 // global supplied by master.html
804 appDisabled = typeof(appDisabled) == 'undefined' ? [] : appDisabled;
808 // previously we did not a good naming policy for module and parts
809 // most things that are called module here, really are 'parts'
810 // new versions should have 'part' as [ module : part ]
813 if (typeof(obj.part) != 'undefined') {
815 var permname = obj.part.join('.');
816 // we now have permission...
817 // obj.moduleOwner '.' lname
819 if (this.hasPermExists(permname) && !this.hasPerm(permname,'S')) {
820 // it's a turned off permission...
821 Roo.log(permname + " is Disabled for this user");
825 if (appDisabled.indexOf(permname) > -1) {
826 Roo.log(permname + " is Disabled for this site");
835 // false parent... use it..
840 if (obj.parent === Pman) {
841 obj.parent = Pman.fakeRoot;
844 if (typeof(obj.parent) == 'undefined') {
845 console.log("Parent is undefined");
852 if (obj.parent === false) {
854 console.log('ignoring top level object (as parent===false found)');
858 // this is an error condition - the parent does not exist..
859 // technically it should not happen..
861 // hack for Pman parent == Pman..
862 if (obj.parent == obj.module) {
870 * DEPRICATED : use Roo.XComponents now..
873 modKey : '00-admin-xxxx',
874 module : Pman.Tab.projectMgr, << really a components..
875 part : [ 'Admin', 'ProjectManager' ]
882 register : function(obj)
885 //this.xregister(obj);
888 // old style calls go in here..
889 // we need to convert the object so that it looks a bit like an XCompoenent..
891 obj.render = function()
894 Roo.log("Skip module, as parent does not exist");
898 //if (typeof(mod) == 'function') {
901 if (typeof(this.region) == 'undefined') {
902 Roo.log("Module does not have region defined, skipping");
906 if (this.module.disabled) {
907 Roo.log("Module disabled, should not rendering")
912 if (!this.parent.layout) {
913 Roo.log("Module parent does not have property layout.")
918 // honour DEPRICATED permname setings..
919 // new code should use PART name, and matching permissions.
920 if (this.permname && this.permname.length) {
921 if (!Pman.hasPerm(this.permname, 'S')) {
926 this.add(this.parent.layout, this.region);
927 this.el = this.layout;
932 // map some of the standard properties..
933 obj.order = obj.modKey;
939 // the other issue we have is that
942 // Roo.log("CALLING XComponent register with : " + obj.name);
944 // this will call xregister as it's the on.register handler..
945 Roo.XComponent.register(obj.isTop ? obj : Roo.apply(obj.module, obj));
948 invertColor : function(c)
952 for(var i = 0; i < 3; i++){
953 ca[i] = parseInt(c.charAt((i*2)+1) + c.charAt((i*2)+2), 16);
958 Roo.each(ca, function(hi) {
959 var h = parseInt(255-hi).toString(16);