/**
  * @param array $config        The Current Forecast Config
  */
 protected function handle6to7($config)
 {
     $columns = array_unique(array_merge(ForecastsDefaults::getWorksheetColumns($this->from_flavor), array('likely_case', 'best_case', 'worst_case')));
     $map = array('likely_case' => 'show_worksheet_likely', 'best_case' => 'show_worksheet_best', 'worst_case' => 'show_worksheet_worst');
     $final = array();
     foreach ($columns as $val) {
         if (!isset($map[$val]) || $config[$map[$val]] == 1) {
             $final[] = $val;
         }
     }
     // save the columns to the worksheet list viewdefs
     $this->client->setWorksheetColumns($this->api, $final, $config['forecast_by']);
     unset($this->api, $this->client);
 }
Пример #2
0
 /**
  * Handle setting the default worksheet_columns back into the db.
  *
  * @param String $forecast_by The Module that we are currently forecasting by
  */
 public function setDefaultWorksheetColumns($forecast_by)
 {
     SugarAutoLoader::load('modules/Forecasts/ForecastsDefaults.php');
     $edition = $forecast_by === 'RevenueLineItems' ? 'ent' : 'pro';
     $columns = ForecastsDefaults::getWorksheetColumns($edition);
     // we need to check the setting for best and worst
     $settings = Forecast::getSettings(true);
     if ($settings['show_worksheet_best'] != 1) {
         // remove best since it's include by default
         foreach ($columns as $i => $column) {
             if ($column === 'best_case') {
                 unset($columns[$i]);
                 break;
             }
         }
     }
     if ($settings['show_worksheet_worst'] == 1) {
         // add worse_Case since it's not include by default
         $columns[] = 'worst_case';
     }
     /* @var $admin Administration */
     $admin = BeanFactory::getBean('Administration');
     $admin->saveSetting('Forecasts', 'worksheet_columns', json_encode($columns), 'base');
     // update the metadata
     $this->updateConfigWorksheetColumnsMetadata($forecast_by);
     // now write out the correct list view
     $this->setWorksheetColumns('base', $columns, $forecast_by);
 }