コード例 #1
0
 /**
  * Upgrade Task to Run
  */
 public function run()
 {
     if (version_compare($this->from_version, '7.0.0', '<') && ($this->toFlavor('ent') || $this->toFlavor('ult'))) {
         $settings = Opportunity::getSettings();
         if ($settings['opps_view_by'] !== 'RevenueLineItems') {
             $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
             return;
         }
         $filename = 'custom/Extension/modules/Opportunities/Ext/Vardefs/sugarfield_date_closed.php';
         if (!is_file($filename)) {
             return;
         }
         require $filename;
         if (!empty($dictionary['Opportunity']['fields'])) {
             $fileString = file_get_contents($filename);
             // PAT-584, need to set the field Expected Close Date to false when upgrade because:
             // In 6.7, the field Expected Close Date is Required and no formula associated out of box.
             // In 7, the field Expected Close Date is Not Required and there's a formula associated out of box.
             // So use steps from PAT-584, it results in a Required field with a formula associated.
             if (isset($dictionary['Opportunity']['fields']['date_closed']['required']) && $dictionary['Opportunity']['fields']['date_closed']['required'] == true) {
                 $this->log("Change Opportunity field date_closed to not required");
                 $fileString = preg_replace('/(\\$dictionary\\[\'Opportunity\'\\]\\[\'fields\'\\]\\[\'date_closed\'\\]\\[\'required\'\\]\\s*=\\s*)true\\s*;/', '${1}false;', $fileString);
                 sugar_file_put_contents_atomic($filename, $fileString);
             }
         }
     }
 }
コード例 #2
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();
 }
コード例 #3
0
 public function run()
 {
     if (!$this->toFlavor('ent') && !$this->toFlavor('ult') || !version_compare($this->from_version, '7.0', '<')) {
         return;
     }
     $settings = Opportunity::getSettings();
     if ($settings['opps_view_by'] !== 'RevenueLineItems') {
         $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
         return;
     }
     // get the get_widget helper and the StandardField Helper
     require_once 'modules/DynamicFields/FieldCases.php';
     require_once 'modules/ModuleBuilder/parsers/StandardField.php';
     // we are working with opportunities
     $module = 'Opportunities';
     $bean = BeanFactory::getBean('Opportunities');
     // the field set we need
     $fields = array('best_case', 'amount', 'worst_case', 'date_closed');
     // loop over each field
     foreach ($fields as $field) {
         // get the field defs
         $field_defs = $bean->getFieldDefinition($field);
         // load the field type up
         $f = get_widget($field_defs['type']);
         // populate the row from the vardefs that were loaded
         $f->populateFromRow($field_defs);
         // lets make sure that the calculated is true
         $f->calculated = true;
         // now lets save, since these are OOB field, we use StandardField
         $df = new StandardField($module);
         $df->setup($bean);
         $f->module = $bean;
         $f->save($df);
     }
 }
コード例 #4
0
ファイル: AccountsApi.php プロジェクト: jglaine/sugar761-ent
 /**
  * Figure out which Opportunity Status Field To Use based on the `opps_view_by` setting
  *
  * @return string
  */
 protected function getOpportunityStatusField()
 {
     $status_field = 'sales_stage';
     // get the opp config
     $opp_config = Opportunity::getSettings();
     if ($opp_config['opps_view_by'] === 'RevenueLineItems') {
         $status_field = 'sales_status';
     }
     return $status_field;
 }
コード例 #5
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'] !== 'Opportunities') {
         $GLOBALS['log']->fatal("Opportunity are 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;
     $labels = $args['labels'];
     $data = $args['chunk'];
     $currencies = array();
     Activity::disable();
     // disable the fts index as well
     /* @var $ftsSearch SugarSearchEngineElastic */
     $ftsSearch = SugarSearchEngineFactory::getInstance();
     $ftsSearch->setForceAsyncIndex(true);
     foreach ($data as $opp_id => $rli_data) {
         /* @var $opp Opportunity */
         $opp = BeanFactory::getBean('Opportunities', $opp_id);
         /* @var $note Note */
         $note = BeanFactory::getBean('Notes');
         $note->parent_id = $opp_id;
         $note->parent_type = 'Opportunities';
         $note->assigned_user_id = $opp->assigned_user_id;
         $note->created_by = $opp->created_by;
         $note->name = 'Previous Associated Revenue Line Items';
         $desc = '';
         foreach ($rli_data as $rli) {
             $desc .= $rli['name'] . "\n";
             foreach ($rli as $field => $value) {
                 if (isset($labels[$field])) {
                     if ($field === 'currency_id') {
                         if (!isset($currencies[$value])) {
                             $currencies[$value] = SugarCurrency::getCurrencyByID($value);
                         }
                         $desc .= " - " . $labels[$field] . ": " . $currencies[$value]->name . "\n";
                     } elseif ($field !== 'name' && $field !== 'opportunity_id') {
                         $desc .= " - " . $labels[$field] . ": " . $value . "\n";
                     }
                 }
             }
             $desc .= "\n\n";
         }
         $note->description = trim($desc);
         $note->save();
     }
     // set it back to the default value from the config.
     $ftsSearch->setForceAsyncIndex(SugarConfig::getInstance()->get('search_engine.force_async_index', false));
     Activity::enable();
     $this->job->succeedJob();
     $this->notifyAssignedUser();
     return true;
 }
コード例 #6
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;
 }
コード例 #7
0
 public function run()
 {
     // get the opportunity settings
     $settings = Opportunity::getSettings();
     // if this key is not setup, then there is a 99.99% chance that it has never been set,
     // so it should be setup.
     if (!isset($settings['opps_view_by']) || empty($settings['opps_view_by'])) {
         SugarAutoLoader::load('modules/Opportunities/OpportunitiesDefaults.php');
         OpportunitiesDefaults::setupOpportunitiesSettings();
         // reload the settings now
         Opportunity::getSettings(true);
     }
 }
 public function run()
 {
     // are we going to 7.6 or newer?
     // if we are and we are not using RLI's this can be skipped
     $settings = Opportunity::getSettings();
     if (version_compare($this->to_version, '7.6', '>=') && $settings['opps_view_by'] !== 'RevenueLineItems') {
         $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
         return;
     }
     $q = "SELECT '' as id,\n                     rli.name,\n                     rli.id as parent_id,\n                     'RevenueLineItems' as parent_type,\n                     1 as draft\n                FROM revenue_line_items rli\n                LEFT JOIN forecast_worksheets fw\n                ON rli.id = fw.parent_id AND fw.parent_type = 'RevenueLineItems'\n                WHERE fw.id IS NULL";
     $this->log('Running Select SQL: ' . $q);
     $r = $this->db->query($q);
     $this->log('Found ' . $this->db->getRowCount($r) . ' RLIs to add to ForecastWorksheets');
     $this->insertRows($r);
 }
コード例 #9
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;
 }
コード例 #10
0
 public function run()
 {
     // are we going to 7.6 or newer?
     // if we are and we are not using RLI's this can be skipped
     $settings = Opportunity::getSettings();
     if (version_compare($this->to_version, '7.6', '>=') && $settings['opps_view_by'] !== 'RevenueLineItems') {
         $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
         return;
     }
     $this->log('Updating Revenue Line Item Rows in Forecast Worksheet');
     $fields = array('name', 'account_id', 'account_name', 'likely_case', 'best_case', 'base_rate', 'worst_case', 'currency_id', 'date_closed', 'date_closed_timestamp', 'probability', 'commit_stage', 'sales_stage', 'assigned_user_id', 'created_by', 'date_entered', 'team_id', 'team_set_id', 'opportunity_id', 'opportunity_name', 'description', 'next_step', 'lead_source', 'product_type', 'campaign_id', 'campaign_name', 'product_template_id', 'product_template_name', 'category_id', 'category_name', 'list_price', 'cost_price', 'discount_price', 'discount_amount', 'quantity', 'total_amount');
     $sqlSet = "%s=(SELECT %s from revenue_line_items r WHERE r.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'RevenueLineItems')";
     $sqlSetArray = array();
     foreach ($fields as $field) {
         $key = $field;
         if (is_array($field)) {
             $key = array_shift(array_keys($field));
             $field = array_shift($field);
         }
         switch ($field) {
             case 'account_name':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT a.name FROM accounts a INNER JOIN revenue_line_items r on\n                            r.account_id = a.id WHERE r.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'RevenueLineItems')", $field);
                 break;
             case 'opportunity_name':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT o.name FROM opportunities o INNER JOIN revenue_line_items r on\n                            r.opportunity_id = o.id WHERE r.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'RevenueLineItems')", $field);
                 break;
             case 'campaign_name':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT c.name FROM campaigns c INNER JOIN revenue_line_items r on\n                            r.campaign_id = c.id WHERE r.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'RevenueLineItems')", $field);
                 break;
             case 'product_template_name':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT p.name FROM product_templates p INNER JOIN revenue_line_items r on\n                            r.product_template_id = p.id WHERE r.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'RevenueLineItems')", $field);
                 break;
             case 'category_name':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT c.name FROM product_categories c INNER JOIN revenue_line_items r on\n                            r.category_id = c.id WHERE r.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'RevenueLineItems')", $field);
                 break;
             default:
                 $sqlSetArray[] = sprintf($sqlSet, $key, $field);
                 break;
         }
     }
     $sql = "update forecast_worksheets SET " . join(",", $sqlSetArray) . "\n          where exists (SELECT * from revenue_line_items r WHERE r.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'RevenueLineItems')";
     $r = $this->db->query($sql);
     $this->log('SQL Ran, Updated ' . $this->db->getAffectedRowCount($r) . ' Rows');
     $sql_delete = "update forecast_worksheets SET deleted = 1 WHERE exists\n                (SELECT * from revenue_line_items r WHERE r.deleted = 1 and\n                    r.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'RevenueLineItems')";
     $this->db->query($sql_delete);
 }
コード例 #11
0
 public function run()
 {
     // are we coming from anything before 7.0?
     if (!version_compare($this->from_version, '7.0', '<')) {
         return;
     }
     $settings = Opportunity::getSettings();
     if ($settings['opps_view_by'] !== 'Opportunities') {
         $this->log('Not using Opportunities; Skipping Upgrade Script');
         return;
     }
     $this->log('Updating Opportunity Rows in Forecast Worksheet');
     $fields = array('name', array('opportunity_name' => 'name'), array('opportunity_id' => 'id'), 'account_id', 'account_name', array('likely_case' => 'amount'), 'best_case', 'base_rate', 'worst_case', 'currency_id', 'date_closed', 'date_closed_timestamp', 'sales_stage', 'probability', 'commit_stage', 'assigned_user_id', 'created_by', 'date_entered', 'team_id', 'team_set_id', 'sales_status', 'description', 'next_step', 'lead_source', array('product_type' => 'opportunity_type'), 'campaign_id', 'campaign_name');
     $sqlSet = "%s=(SELECT %s from opportunities o WHERE o.id = fw.parent_id and fw.parent_type = 'Opportunities')";
     $sqlSetArray = array();
     foreach ($fields as $field) {
         $key = $field;
         if (is_array($field)) {
             $key = array_shift(array_keys($field));
             $field = array_shift($field);
         }
         switch ($field) {
             case 'account_name':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT a.name FROM accounts a INNER JOIN accounts_opportunities ac on\n                        ac.account_id = a.id and ac.deleted = 0 WHERE\n                        ac.opportunity_id = fw.parent_id and fw.parent_type = 'Opportunities')", $field);
                 break;
             case 'account_id':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT a.id FROM accounts a INNER JOIN accounts_opportunities ac on\n                        ac.account_id = a.id and ac.deleted = 0 WHERE\n                        ac.opportunity_id = fw.parent_id and fw.parent_type = 'Opportunities')", $field);
                 break;
             case 'campaign_name':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT c.name FROM campaigns c INNER JOIN opportunities o on\n                            o.campaign_id = c.id WHERE o.id = fw.parent_id and fw.parent_type = 'Opportunities')", $field);
                 break;
             case 'campaign_id':
                 $sqlSetArray[] = sprintf("%s = (SELECT DISTINCT c.id FROM campaigns c INNER JOIN opportunities o on\n                            o.campaign_id = c.id WHERE o.id = fw.parent_id and fw.parent_type = 'Opportunities')", $field);
                 break;
             default:
                 $sqlSetArray[] = sprintf($sqlSet, $key, $field);
                 break;
         }
     }
     $sql = "update forecast_worksheets as fw SET " . join(",", $sqlSetArray) . "\n          where exists (SELECT * from opportunities o WHERE o.id = fw.parent_id and fw.parent_type = 'Opportunities')";
     $r = $this->db->query($sql);
     $this->log('SQL Ran, Updated ' . $this->db->getAffectedRowCount($r) . ' Rows');
     $sql_delete = "update forecast_worksheets SET deleted = 1 WHERE exists\n                (SELECT * from opportunities o WHERE o.deleted = 1 and\n                  o.id = forecast_worksheets.parent_id and forecast_worksheets.parent_type = 'Opportunities')";
     $this->db->query($sql_delete);
 }
コード例 #12
0
 public function run()
 {
     // are we going to 7.6 or newer?
     // if we are and we are not using RLI's this can be skipped
     $settings = Opportunity::getSettings();
     if (version_compare($this->to_version, '7.6', '>=') && $settings['opps_view_by'] !== 'RevenueLineItems') {
         $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
         return;
     }
     $this->log('Updating Revenue Line Items TimeStamp fields');
     $sql = "select id, date_closed from revenue_line_items where deleted = 0";
     $results = $this->db->query($sql);
     $updateSql = "UPDATE revenue_line_items SET date_closed_timestamp = '%d' where id = '%s'";
     while ($row = $this->db->fetchRow($results)) {
         $this->db->query(sprintf($updateSql, strtotime($row['date_closed']), $row['id']));
     }
     $this->log('Done Updating Revenue Line Items TimeStamp fields');
 }
コード例 #13
0
 public function run()
 {
     // are we coming from anything before 7.0?
     if (!version_compare($this->from_version, '7.0', '<')) {
         return;
     }
     // are we going to 7.6 or newer?
     // if we are and we are not using RLI's this can be skipped
     $settings = Opportunity::getSettings();
     if (version_compare($this->to_version, '7.6', '>=') && $settings['opps_view_by'] !== 'RevenueLineItems') {
         $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
         return;
     }
     $this->log('Syncing Accounts to RLI Table');
     $sql = "UPDATE revenue_line_items rli\n               SET account_id = (SELECT ac.account_id\n                                 FROM accounts_opportunities ac\n                                 WHERE ac.opportunity_id = rli.opportunity_id and ac.deleted = 0)\n               WHERE rli.account_id IS NULL or rli.account_id = ''";
     $r = $this->db->query($sql);
     $this->log('SQL Ran, Updated ' . $this->db->getAffectedRowCount($r) . ' Rows');
     $this->log('Done Syncing Accounts to RLI Table');
 }
コード例 #14
0
 public function run()
 {
     // are we coming from anything before 7.0?
     if (!version_compare($this->from_version, '7.0', '<')) {
         return;
     }
     $settings = Opportunity::getSettings();
     if ($settings['opps_view_by'] !== 'RevenueLineItems') {
         $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
         return;
     }
     $this->log('Updating Opportunity Rollup Fields');
     $sql = "SELECT opportunity_id               AS opp_id,\n                          Sum(likely_case)             AS likely,\n                          Sum(worst_case)              AS worst,\n                          Sum(best_case)               AS best,\n                          Max(t.date_closed)           AS date_closed,\n                          Max(t.date_closed_timestamp) AS date_closed_timestamp,\n                          Count(0)                     AS total,\n                          ( won + lost )               AS total_closed,\n                          lost\n                   FROM   (SELECT rli.opportunity_id,\n                                  (rli.likely_case/rli.base_rate) as likely_case,\n                                  (rli.worst_case/rli.base_rate) as worst_case,\n                                  (rli.best_case/rli.base_rate) as best_case,\n                                  rli.date_closed,\n                                  rli.date_closed_timestamp,\n                                  CASE\n                                    WHEN rli.sales_stage = 'Closed Lost' THEN 1\n                                    ELSE 0\n                                  end AS lost,\n                                  CASE\n                                    WHEN rli.sales_stage = 'Closed Won' THEN 1\n                                    ELSE 0\n                                  end AS won\n                           FROM   revenue_line_items AS rli\n                           WHERE  rli.deleted = 0) AS t\n                   GROUP  BY t.opportunity_id, (won + lost), lost";
     $results = $this->db->query($sql);
     $sql = "UPDATE opportunities SET\n                    amount=(%f*base_rate),best_case=(%f*base_rate),worst_case=(%f*base_rate),date_closed='%s',date_closed_timestamp='%s',\n                    sales_status='%s',total_revenue_line_items='%d',closed_revenue_line_items='%d' WHERE id = '%s'";
     while ($row = $this->db->fetchRow($results)) {
         $row['sales_status'] = $row['total'] == 0 || $row['total'] > $row['total_closed'] ? 'In Progress' : $row['lost'] == $row['total'] ? 'Closed Lost' : 'Closed Won';
         $this->db->query(sprintf($sql, $row['likely'], $row['best'], $row['worst'], $row['date_closed'], $row['date_closed_timestamp'], $row['sales_status'], $row['total'], $row['total_closed'], $row['opp_id']));
     }
     $this->log('Done Updating Opportunity Rollup Fields');
 }
コード例 #15
0
 /**
  * Upgrade Task to Run
  */
 public function run()
 {
     if (version_compare($this->from_version, '7.0.0', '<') && $this->toFlavor('ent')) {
         $settings = Opportunity::getSettings();
         if ($settings['opps_view_by'] !== 'RevenueLineItems') {
             $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
             return;
         }
         $fields = array('sales_stage', 'probability', 'commit_stage');
         require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
         $this->log('Processing Opportunity RecordView');
         $recordViewDefsParser = ParserFactory::getParser(MB_RECORDVIEW, 'Opportunities', null, null, 'base');
         if ($this->removeFields($recordViewDefsParser, $fields)) {
             $recordViewDefsParser->handleSave(false);
         }
         $this->log('Processing Opportunity ListView');
         $recordViewDefsParser = ParserFactory::getParser(MB_LISTVIEW, 'Opportunities', null, null, 'base');
         if ($this->removeFields($recordViewDefsParser, $fields)) {
             $recordViewDefsParser->handleSave(false);
         }
         $modules = array('Accounts', 'Contacts', 'Campaigns', 'Documents');
         global $modInvisList;
         if (array_search('Project', $modInvisList)) {
             $modules[] = 'Project';
         }
         foreach ($modules as $module) {
             $this->log('Processing Opportunity SubPanel for ' . $module . ' module');
             if (isModuleBWC($module)) {
                 require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php';
                 $pf = new SubpanelMetaDataParser('opportunities', $module);
             } else {
                 $pf = ParserFactory::getParser(MB_LISTVIEW, $module, null, 'opportunities');
             }
             if ($this->removeFields($pf, $fields)) {
                 $pf->handleSave(false);
             }
         }
     }
 }
コード例 #16
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);
     }
 }
コード例 #17
0
}
/* @var $quote Quote */
$quote = BeanFactory::getBean('Quotes', $_REQUEST['record']);
if ($quote->getRelatedOpportunityCount() > 0) {
    global $app_strings;
    printf("<span class=\"error\">%s</span>", $app_strings['ERR_QUOTE_CONVERTED']);
} elseif (empty($_REQUEST["opportunity_subject"])) {
    $LBLITUP = $app_strings['ERR_OPPORTUNITY_NAME_MISSING'];
    printf("<span class=\"error\">{$LBLITUP}</span>");
    generate_name_form($_REQUEST);
} elseif (query_opportunity_subject_exists($_REQUEST["opportunity_subject"]) > 0) {
    $LBLITUP = $app_strings['ERR_OPPORTUNITY_NAME_DUPE'];
    printf("<span class=\"error\">{$LBLITUP}</span>", $_REQUEST["opportunity_subject"]);
    generate_name_form($_REQUEST);
} else {
    $oppSettings = Opportunity::getSettings();
    /* @var $opp Opportunity */
    $opp = BeanFactory::getBean('Opportunities');
    $opp->id = create_guid();
    $opp->new_with_id = true;
    printf("%s<br><br>", $opp->id);
    $opp->assigned_user_id = $quote->assigned_user_id;
    $opp->date_closed = $quote->date_quote_expected_closed;
    $opp->name = $_REQUEST['opportunity_subject'];
    $opp->assigned_user_name = $quote->assigned_user_name;
    $opp->lead_source = isset($app_list_strings['lead_source_dom']['Self Generated']) ? 'Self Generated' : null;
    //'Self Generated';
    $opp->opportunity_type = isset($app_list_strings['opportunity_type_dom']['New Business']) ? $app_list_strings['opportunity_type_dom']['New Business'] : null;
    //'New Business';
    $opp->team_id = $quote->team_id;
    $opp->quote_id = $quote->id;
コード例 #18
0
 /**
  * @return array
  */
 protected static function useRevenueLineItems()
 {
     // get the OpportunitySettings
     $settings = Opportunity::getSettings();
     return isset($settings['opps_view_by']) && $settings['opps_view_by'] === 'RevenueLineItems';
 }
コード例 #19
0
 /**
  * {@inheritdoc}
  */
 public function bean_implements($interface)
 {
     // if we are installing, we want to return false, really hacky, but OOB default on ENT and ULT is to not
     // have RevenueLineItems ACLed
     if (isset($GLOBALS['installing']) && $GLOBALS['installing'] === true) {
         return false;
     }
     // if we are using opportunities with RLI's we should return true, otherwise return false
     $settings = Opportunity::getSettings();
     if (isset($settings['opps_view_by']) && $settings['opps_view_by'] === 'RevenueLineItems') {
         switch ($interface) {
             case 'ACL':
                 return true;
         }
     }
     return false;
 }