当前位置: 首页>>代码示例>>PHP>>正文


PHP Opportunity::getSettings方法代码示例

本文整理汇总了PHP中Opportunity::getSettings方法的典型用法代码示例。如果您正苦于以下问题:PHP Opportunity::getSettings方法的具体用法?PHP Opportunity::getSettings怎么用?PHP Opportunity::getSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opportunity的用法示例。


在下文中一共展示了Opportunity::getSettings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * 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);
             }
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:30,代码来源:7_OpportunityUpdateDateClosed.php

示例2: handleSave

 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();
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:35,代码来源:view.resetmodule.php

示例3: run

 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);
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:35,代码来源:7_OpportunityFixCalculatedFields.php

示例4: getOpportunityStatusField

 /**
  * 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;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:15,代码来源:AccountsApi.php

示例5: run

 /**
  * @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;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:58,代码来源:SugarJobCreateRevenueLineItemNotes.php

示例6: configSave

 /**
  * 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;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:59,代码来源:OpportunitiesConfigApi.php

示例7: run

 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);
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:13,代码来源:2_OpportunitySetViewBy.php

示例8: run

 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);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:15,代码来源:2_RevenueLineItemCreateForecastWorksheetRecords.php

示例9: run

 /**
  * @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;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:20,代码来源:SugarJobCreateRevenueLineItems.php

示例10: run

 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);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:46,代码来源:2_RevenueLineItemSyncToForecastWorksheet.php

示例11: run

 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);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:45,代码来源:2_OpportunitySyncToForecastWorksheet.php

示例12: run

 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');
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:18,代码来源:2_RevenueLineItemUpdateTimeStamp.php

示例13: run

 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');
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:19,代码来源:2_RevenueLineItemAccountSync.php

示例14: run

 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');
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:21,代码来源:3_OpportunityUpdateRollupFields.php

示例15: run

 /**
  * 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);
             }
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:42,代码来源:7_OpportunityRemoveHiddenEntFields.php


注:本文中的Opportunity::getSettings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。