/********************************************************************************* * SugarCRM Community Edition is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the * Free Software Foundation with the addition of the following permission added * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License along with * this program; if not, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ initMySugar=function(){SUGAR.mySugar=function(){var originalLayout=null;var configureDashletId=null;var currentDashlet=null;var leftColumnInnerHTML=null;var leftColObj=null;var maxCount;var warningLang;var closeDashletsDialogTimer=null;var activeTab=activePage;var current_user=current_user_id;var module=moduleName;var charts=new Object();if(module=='Dashboard'){cookiePageIndex=current_user+"_activeDashboardPage";} else{cookiePageIndex=current_user+"_activePage";} var homepage_dd;return{getLayout:function(asString){columns=new Array();for(je=0;je<3;je++){dashlets=document.getElementById('col_'+activeTab+'_'+je);if(dashlets!=null){dashletIds=new Array();for(wp=0;wp=SUGAR.mySugar.maxCount){alert(SUGAR.language.get('app_strings','LBL_MAX_DASHLETS_REACHED'));return;} ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_ADDING_DASHLET'));var success=function(data){colZero=document.getElementById('col_'+activeTab+'_0');newDashlet=document.createElement('li');newDashlet.id='dashlet_'+data.responseText;newDashlet.className='noBullet active';newDashlet.innerHTML='
';colZero.insertBefore(newDashlet,colZero.firstChild);var finishRetrieve=function(){dashletEntire=document.getElementById('dashlet_entire_'+data.responseText);dd=new ygDDList('dashlet_'+data.responseText);dd.setHandleElId('dashlet_header_'+data.responseText);dd.dashletID=data.responseText;dd.onMouseDown=SUGAR.mySugar.onDrag;dd.onDragDrop=SUGAR.mySugar.onDrop;ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_ADDED_DASHLET'));dashletRegion=YAHOO.util.Dom.getRegion(dashletEntire);dashletEntire.style.position='relative';dashletEntire.style.height='1px';dashletEntire.style.top='0px';dashletEntire.className='dashletPanel';var anim=new YAHOO.util.Anim('dashlet_entire_'+data.responseText,{height:{to:dashletRegion.bottom-dashletRegion.top}},.5);anim.onComplete.subscribe(function(){document.getElementById('dashlet_entire_'+data.responseText).style.height='100%';});anim.animate();newLayout=SUGAR.mySugar.getLayout(true);SUGAR.mySugar.saveLayout(newLayout);} if(type=='module'||type=='web'){url=null;type='module';} else if(type=='predefined_chart'){url='predefined_chart';type='predefined_chart';} else if(type=='chart'){url='chart';type='chart';} SUGAR.mySugar.retrieveDashlet(data.responseText,url,finishRetrieve,true);} var cObj=YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=1&module='+module+'&action=DynamicAction&DynamicAction=addDashlet&activeTab='+activeTab+'&id='+id+'&type='+type+'&type_module='+encodeURIComponent(type_module),{success:success,failure:success},null);return false;},showDashletsDialog:function(){columns=SUGAR.mySugar.getLayout();if(this.closeDashletsDialogTimer!=null){window.clearTimeout(this.closeDashletsDialogTimer);} var num_dashlets=0;var i=0;for(i=0;i<3;i++){if(typeof columns[i]!="undefined"){num_dashlets=num_dashlets+columns[i].length;}} if((num_dashlets)>=SUGAR.mySugar.maxCount){alert(SUGAR.language.get('app_strings','LBL_MAX_DASHLETS_REACHED'));return;} ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_LOADING'));var success=function(data){eval(data.responseText);dashletsListDiv=document.getElementById('dashletsList');dashletsListDiv.innerHTML=response['html'];document.getElementById('dashletsDialog_c').style.display='';SUGAR.mySugar.dashletsDialog.show();eval(response['script']);ajaxStatus.hideStatus();} var cObj=YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=true&module='+module+'&action=DynamicAction&DynamicAction=dashletsDialog',{success:success,failure:success});return false;},closeDashletsDialog:function(){SUGAR.mySugar.dashletsDialog.hide();if(this.closeDashletsDialogTimer!=null){window.clearTimeout(this.closeDashletsDialogTimer);} this.closeDashletsDialogTimer=window.setTimeout("document.getElementById('dashletsDialog_c').style.display = 'none';",2000);},toggleDashletCategories:function(category){document.getElementById('search_string').value='';document.getElementById('searchResults').innerHTML='';var moduleTab=document.getElementById('moduleCategory');var moduleTabAnchor=document.getElementById('moduleCategoryAnchor');var moduleListDiv=document.getElementById('moduleDashlets');var chartTab=document.getElementById('chartCategory');var chartTabAnchor=document.getElementById('chartCategoryAnchor');var chartListDiv=document.getElementById('chartDashlets');var toolsTab=document.getElementById('toolsCategory');var toolsTabAnchor=document.getElementById('toolsCategoryAnchor');var toolsListDiv=document.getElementById('toolsDashlets');var webTab=document.getElementById('webCategory');var webTabAnchor=document.getElementById('webCategoryAnchor');var webListDiv=document.getElementById('webDashlets');switch(category){case'module':moduleTab.className='active';moduleTabAnchor.className='current';moduleListDiv.style.display='';chartTab.className='';chartTabAnchor.className='';chartListDiv.style.display='none';toolsTab.className='';toolsTabAnchor.className='';toolsListDiv.style.display='none';webTab.className='';webTabAnchor.className='';webListDiv.style.display='none';break;case'chart':moduleTab.className='';moduleTabAnchor.className='';moduleListDiv.style.display='none';chartTab.className='active';chartTabAnchor.className='current';chartListDiv.style.display='';toolsTab.className='';toolsTabAnchor.className='';toolsListDiv.style.display='none';webTab.className='';webTabAnchor.className='';webListDiv.style.display='none';break;case'tools':moduleTab.className='';moduleTabAnchor.className='';moduleListDiv.style.display='none';chartTab.className='';chartTabAnchor.className='';chartListDiv.style.display='none';toolsTab.className='active';toolsTabAnchor.className='current';toolsListDiv.style.display='';webTab.className='';webTabAnchor.className='';webListDiv.style.display='none';break;case'web':moduleTab.className='';moduleTabAnchor.className='';moduleListDiv.style.display='none';chartTab.className='';chartTabAnchor.className='';chartListDiv.style.display='none';toolsTab.className='';toolsTabAnchor.className='';toolsListDiv.style.display='none';webTab.className='active';webTabAnchor.className='current';webListDiv.style.display='';break;default:break;} document.getElementById('search_category').value=category;},searchDashlets:function(searchStr,searchCategory){var moduleTab=document.getElementById('moduleCategory');var moduleTabAnchor=document.getElementById('moduleCategoryAnchor');var moduleListDiv=document.getElementById('moduleDashlets');var chartTab=document.getElementById('chartCategory');var chartTabAnchor=document.getElementById('chartCategoryAnchor');var chartListDiv=document.getElementById('chartDashlets');var toolsTab=document.getElementById('toolsCategory');var toolsTabAnchor=document.getElementById('toolsCategoryAnchor');var toolsListDiv=document.getElementById('toolsDashlets');if(moduleTab!=null&&chartTab!=null&&toolsTab!=null){moduleListDiv.style.display='none';chartListDiv.style.display='none';toolsListDiv.style.display='none';} else{chartListDiv.style.display='none';} var searchResultsDiv=document.getElementById('searchResults');searchResultsDiv.style.display='';var success=function(data){eval(data.responseText);searchResultsDiv.innerHTML=response['html'];} var cObj=YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=true&module='+module+'&action=DynamicAction&DynamicAction=searchDashlets&search='+searchStr+'&category='+searchCategory,{success:success,failure:success});return false;},collapseList:function(chartList){document.getElementById(chartList+'List').style.display='none';document.getElementById(chartList+'ExpCol').innerHTML='';},expandList:function(chartList){document.getElementById(chartList+'List').style.display='';document.getElementById(chartList+'ExpCol').innerHTML='';},collapseReportList:function(reportChartList){document.getElementById(reportChartList+'ReportsChartDashletsList').style.display='none';document.getElementById(reportChartList+'ExpCol').innerHTML='';},expandReportList:function(reportChartList){document.getElementById(reportChartList+'ReportsChartDashletsList').style.display='';document.getElementById(reportChartList+'ExpCol').innerHTML='';},clearSearch:function(){document.getElementById('search_string').value='';var moduleTab=document.getElementById('moduleCategory');var moduleTabAnchor=document.getElementById('moduleCategoryAnchor');var moduleListDiv=document.getElementById('moduleDashlets');document.getElementById('searchResults').innerHTML='';if(moduleTab!=null){SUGAR.mySugar.toggleDashletCategories('module');} else{document.getElementById('searchResults').style.display='none';document.getElementById('chartDashlets').style.display='';}},doneAddDashlets:function(){SUGAR.mySugar.dashletsDialog.hide();return false;},renderDashletsDialog:function(){var minHeight=120;var maxHeight=520;var minMargin=16;var pageHeight=document.documentElement.clientHeight;var height=Math.min(maxHeight,pageHeight-minMargin*2);height=Math.max(height,minHeight);SUGAR.mySugar.dashletsDialog=new YAHOO.widget.Dialog("dashletsDialog",{width:"480px",height:height+"px",fixedcenter:true,draggable:false,visible:false,modal:true,close:false});var listeners=new YAHOO.util.KeyListener(document,{keys:27},{fn:function(){SUGAR.mySugar.closeDashletsDialog();}});SUGAR.mySugar.dashletsDialog.cfg.queueProperty("keylisteners",listeners);document.getElementById('dashletsDialog').style.display='';SUGAR.mySugar.dashletsDialog.render();document.getElementById('dashletsDialog_c').style.display='none';}};}();};