Ejemplo n.º 1
0
 function action_SaveDropDown()
 {
     require_once 'modules/ModuleBuilder/parsers/parser.dropdown.php';
     $parser = new ParserDropDown();
     $parser->saveDropDown($_REQUEST);
     $this->view = 'dropdowns';
 }
Ejemplo n.º 2
0
 /**
  * Forecast Override since we have custom logic that needs to be ran
  *
  * {@inheritdoc}
  */
 public function forecastsConfigSave(ServiceBase $api, array $args)
 {
     //acl check, only allow if they are module admin
     if (!$api->user->isAdmin() && !$api->user->isDeveloperForModule('Forecasts')) {
         // No create access so we construct an error message and throw the exception
         $failed_module_strings = return_module_language($GLOBALS['current_language'], 'forecasts');
         $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);
     }
     $admin = BeanFactory::getBean('Administration');
     //track what settings have changed to determine if timeperiods need rebuilt
     $prior_forecasts_settings = $admin->getConfigForModule('Forecasts', $api->platform);
     //If this is a first time setup, default prior settings for timeperiods to 0 so we may correctly recalculate
     //how many timeperiods to build forward and backward.  If we don't do this we would need the defaults to be 0
     if (empty($prior_forecasts_settings['is_setup'])) {
         $prior_forecasts_settings['timeperiod_shown_forward'] = 0;
         $prior_forecasts_settings['timeperiod_shown_backward'] = 0;
     }
     $upgraded = 0;
     if (!empty($prior_forecasts_settings['is_upgrade'])) {
         $db = DBManagerFactory::getInstance();
         // check if we need to upgrade opportunities when coming from version below 6.7.x.
         $upgraded = $db->getOne("SELECT count(id) AS total FROM upgrade_history\n                    WHERE type = 'patch' AND status = 'installed' AND version LIKE '6.7.%'");
         if ($upgraded == 1) {
             //TODO-sfa remove this once the ability to map buckets when they get changed is implemented (SFA-215).
             $args['has_commits'] = true;
         }
     }
     if (isset($args['show_custom_buckets_options'])) {
         $json = getJSONobj();
         $_args = array('dropdown_lang' => isset($_SESSION['authenticated_user_language']) ? $_SESSION['authenticated_user_language'] : $GLOBALS['current_language'], 'dropdown_name' => 'commit_stage_custom_dom', 'view_package' => 'studio', 'list_value' => $json->encode($args['show_custom_buckets_options']), 'skip_sync' => true);
         $_REQUEST['view_package'] = 'studio';
         require_once 'modules/ModuleBuilder/parsers/parser.dropdown.php';
         $parser = new ParserDropDown();
         $parser->saveDropDown($_args);
         unset($args['show_custom_buckets_options']);
     }
     // we do the double check here since the front ent will send one one value if the input is empty
     if (empty($args['worksheet_columns']) || empty($args['worksheet_columns'][0])) {
         // set the defaults
         $args['worksheet_columns'] = array('commit_stage', 'parent_name', 'likely_case');
         if ($args['show_worksheet_best'] == 1) {
             $args['worksheet_columns'][] = 'best_case';
         }
         if ($args['show_worksheet_worst'] == 1) {
             $args['worksheet_columns'][] = 'worst_case';
         }
     }
     //reload the settings to get the current settings
     $current_forecasts_settings = parent::configSave($api, $args);
     // setting are saved, reload the setting in the ForecastBean just in case.
     Forecast::getSettings(true);
     // now that we have saved the setting, we need to sync all the data if
     // this is being upgraded or the forecast was not setup before.
     if ($upgraded || empty($prior_forecasts_settings['is_setup'])) {
         if ($args['forecast_by'] === 'Opportunities') {
             SugarAutoLoader::load('include/SugarQueue/jobs/SugarJobUpdateOpportunities.php');
             SugarJobUpdateOpportunities::updateOpportunitiesForForecasting();
         } else {
             SugarAutoLoader::load('include/SugarQueue/jobs/SugarJobUpdateRevenueLineItems.php');
             SugarJobUpdateRevenueLineItems::scheduleRevenueLineItemUpdateJobs();
         }
     }
     // did this change?
     if ($prior_forecasts_settings['worksheet_columns'] !== $args['worksheet_columns']) {
         $this->setWorksheetColumns($api, $args['worksheet_columns'], $current_forecasts_settings['forecast_by']);
     }
     //if primary settings for timeperiods have changed, then rebuild them
     if ($this->timePeriodSettingsChanged($prior_forecasts_settings, $current_forecasts_settings)) {
         $timePeriod = TimePeriod::getByType($current_forecasts_settings['timeperiod_interval']);
         $timePeriod->rebuildForecastingTimePeriods($prior_forecasts_settings, $current_forecasts_settings);
     }
     return $current_forecasts_settings;
 }
Ejemplo n.º 3
0
 public function action_SaveDropDown()
 {
     $parser = new ParserDropDown();
     $parser->saveDropDown($_REQUEST);
     MetaDataManager::refreshSectionCache(MetaDataManager::MM_LABELS);
     MetaDataManager::refreshSectionCache(MetaDataManager::MM_ORDEREDLABELS);
     MetaDataManager::refreshSectionCache(MetaDataManager::MM_EDITDDFILTERS);
     $this->view = 'dropdowns';
 }
Ejemplo n.º 4
0
 /**
  * Add or Remove the RevenueLineItems Module to the Parent Type dropdown List
  *
  * @param bool $add Defaults to `true`
  */
 protected function setRevenueLineItemInParentRelateDropDown($add = true)
 {
     $rli = BeanFactory::getBean('RevenueLineItems');
     // get the default system language
     $default_lang = SugarConfig::getInstance()->get('default_language');
     // get the default app_list_strings and the default language for Revenue Line Items
     $app_list_stings = return_app_list_strings_language($default_lang);
     $module_lang = return_module_language($default_lang, 'RevenueLineItems');
     // What lists need updating
     $listsToUpdate = array('moduleList', 'parent_type_display', 'record_type_display_notes', 'record_type_display');
     // load the Dropdown parser so it can easily be saved
     SugarAutoLoader::load('modules/ModuleBuilder/parsers/parser.dropdown.php');
     $dd_parser = new ParserDropDown();
     foreach ($listsToUpdate as $list_key) {
         $list = $app_list_stings[$list_key];
         $hasRLI = isset($list[$rli->module_name]);
         if ($add && !$hasRLI) {
             // get the translated value
             $list[$rli->module_name] = $module_lang['LBL_MODULE_NAME'];
             $GLOBALS['app_list_strings'][$list_key][$rli->module_name] = $module_lang['LBL_MODULE_NAME'];
         } elseif (!$add && $hasRLI) {
             unset($GLOBALS['app_list_strings'][$list_key][$rli->module_name]);
             unset($list[$rli->module_name]);
         } else {
             // nothing changed, we can continue
             continue;
         }
         // the parser need all the values to be in their own array with the key first then the value
         $new_list = array();
         foreach ($list as $k => $v) {
             $new_list[] = array($k, $v);
         }
         $params = array('dropdown_name' => $list_key, 'dropdown_lang' => $default_lang, 'list_value' => json_encode($new_list), 'view_package' => 'studio', 'use_push' => $list_key == 'moduleList');
         // for some reason, the ParserDropDown class uses $_REQUEST vs getting it from what
         // was passed in.
         $_REQUEST['view_package'] = 'studio';
         $dd_parser->saveDropDown($params);
         // clean up the request object
         unset($_REQUEST['view_package']);
     }
 }