コード例 #1
0
 function handleSave()
 {
     $out = "<script>ajaxStatus.flashStatus(SUGAR.language.get('app_strings', 'LBL_REQUEST_PROCESSED'), 2000);</script>";
     if (!empty($_REQUEST['relationships'])) {
         $out .= $this->removeCustomRelationships();
     }
     if (!empty($_REQUEST['fields'])) {
         $out .= $this->removeCustomFields();
     }
     if (!empty($_REQUEST['layouts'])) {
         $out .= $this->removeCustomLayouts();
     }
     if (!empty($_REQUEST['labels'])) {
         $out .= $this->removeCustomLabels();
     }
     if (!empty($_REQUEST['extensions'])) {
         $out .= $this->removeCustomExtensions();
     }
     if ($this->module === 'Opportunities') {
         $opp_settings = Opportunity::getSettings();
         if ($opp_settings['opps_view_by'] == 'RevenueLineItems') {
             require_once 'modules/Opportunities/include/OpportunityWithRevenueLineItem.php';
             $opp_setup = new OpportunityWithRevenueLineItem();
             $opp_setup->doMetadataConvert();
             $out .= 'Enabling Opportunities with RevenueLineItems<br />';
         }
     }
     $out .= "Complete!";
     $ajax = new AjaxCompose();
     $ajax->addCrumb(translate('LBL_STUDIO'), 'ModuleBuilder.main("studio")');
     $ajax->addCrumb(translate($this->module), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->module . '")');
     $ajax->addCrumb("Reset " . translate($this->module), '');
     $ajax->addSection('center', "Reset " . translate($this->module), $out);
     echo $ajax->getJavascript();
 }
コード例 #2
0
 /**
  * Opportunity Override since we have custom logic that needs to be ran
  *
  * {@inheritdoc}
  */
 public function configSave(ServiceBase $api, array $args)
 {
     //acl check, only allow if they are module admin
     if (!$api->user->isAdmin() && !$api->user->isDeveloperForModule('Opportunities')) {
         // No create access so we construct an error message and throw the exception
         $failed_module_strings = return_module_language($GLOBALS['current_language'], 'Opportunities');
         $moduleName = $failed_module_strings['LBL_MODULE_NAME'];
         $args = null;
         if (!empty($moduleName)) {
             $args = array('moduleName' => $moduleName);
         }
         throw new SugarApiExceptionNotAuthorized($GLOBALS['app_strings']['EXCEPTION_CHANGE_MODULE_CONFIG_NOT_AUTHORIZED'], $args);
     }
     $prior_settings = Opportunity::getSettings();
     // figure out how we should rollup when going back to Opps only
     $date_rollup_type = 'latest';
     if (isset($args['opps_closedate_rollup'])) {
         $date_rollup_type = $args['opps_closedate_rollup'];
         unset($args['opps_closedate_rollup']);
     }
     $this->skipMetadataRefresh = true;
     $settings = parent::configSave($api, $args);
     // reload the settings in the opportunity bean
     Opportunity::getSettings(true);
     $hasChanged = $prior_settings['opps_view_by'] !== $settings['opps_view_by'];
     if ($hasChanged) {
         $max_execution_time = ini_get('max_execution_time');
         if ($max_execution_time != 0 && $max_execution_time < 300) {
             ini_set('max_execution_time', 300);
         }
         /* @var $converter OpportunityWithOutRevenueLineItem|OpportunityWithRevenueLineItem */
         switch ($settings['opps_view_by']) {
             case 'Opportunities':
                 require_once 'modules/Opportunities/include/OpportunityWithOutRevenueLineItem.php';
                 $converter = new OpportunityWithOutRevenueLineItem();
                 $converter->setDateClosedMigrationParam($date_rollup_type);
                 break;
             case 'RevenueLineItems':
                 require_once 'modules/Opportunities/include/OpportunityWithRevenueLineItem.php';
                 $converter = new OpportunityWithRevenueLineItem();
                 break;
         }
         // actually trigger the conversion here
         // do metadata first
         $converter->doMetadataConvert();
         // then do data
         $converter->doDataConvert();
         require_once 'modules/Home/UnifiedSearchAdvanced.php';
         register_shutdown_function(array('UnifiedSearchAdvanced', 'clearCache'));
         // we need to refresh the cache but do it in the shutdown for this process
         register_shutdown_function(array('MetaDataManager', 'refreshCache'));
     }
     return $settings;
 }
コード例 #3
0
 public function run()
 {
     // if we are not going to ent or ult, we need to kick out
     if (!in_array(strtolower($this->to_flavor), $this->validFlavors)) {
         return;
     }
     // to run this we must be coming any version of 7 before 7.6
     if (version_compare($this->from_version, '7.0', '>=') && version_compare($this->from_version, '7.6', '<')) {
         SugarAutoLoader::load('modules/Opportunities/include/OpportunityWithRevenueLineItem.php');
         SugarAutoLoader::load('modules/ModuleBuilder/Module/StudioModuleFactory.php');
         // clear out the studio module cache cause it will be wrong!
         StudioModuleFactory::clearModuleCache('Opportunities');
         // in the upgrade, we only want to do the metadata conversion
         $converter = new OpportunityWithRevenueLineItem();
         $converter->doMetadataConvert();
         // just on the off chance that the formula got put into a custom file, we need to make sure it contains
         // the new hotness
         $this->fixRollupFormulas();
         $admin = BeanFactory::getBean('Administration');
         $admin->saveSetting('Opportunities', 'opps_view_by', 'RevenueLineItems', 'base');
         Opportunity::getSettings(true);
     }
 }
コード例 #4
0
 /**
  * @param string $data The job data set for this particular Scheduled Job instance
  * @return boolean true if the run succeeded; false otherwise
  */
 public function run($data)
 {
     $settings = Opportunity::getSettings();
     if (isset($settings['opps_view_by']) && $settings['opps_view_by'] !== 'RevenueLineItems') {
         $GLOBALS['log']->fatal("Opportunity are not being used with Revenue Line Items. " . __CLASS__ . " should not be running");
         return false;
     }
     $args = json_decode(html_entity_decode($data), true);
     $this->job->runnable_ran = true;
     // use the processWorksheetDataChunk to run the code.
     SugarAutoLoader::load('modules/Opportunities/include/OpportunityWithRevenueLineItem.php');
     OpportunityWithRevenueLineItem::processOpportunityIds($args['data']);
     $this->job->succeedJob();
     $this->notifyAssignedUser();
     return true;
 }