/** * Add and Remove fields from all the list views * * @param array $fieldMap How are we going to change the fields * @return array The Modules which had their subpanels affected */ public function processListViews(array $fieldMap) { // get the views for the module $mm = MetadataManager::getManager(); $views = $mm->getModuleViews('Opportunities'); // fix the selected-list view $this->processSelectedListView($fieldMap); // fix the dupecheck-list view $this->processDupeCheckListView($fieldMap); // get the generic list view $this->processListView($fieldMap); // get the mobile list view now $this->processMobileListView($fieldMap); $subpanel_modules = array('Opportunities'); $links = $this->bean->get_linked_fields(); foreach ($links as $link => $def) { if ($this->bean->load_relationship($link) && $this->bean->{$link} instanceof Link2) { $linkname = $this->bean->{$link}->getRelatedModuleLinkName(); if (!empty($linkname)) { $this->processListView($fieldMap, $this->bean->{$link}->getRelatedModuleName(), $linkname); $subpanel_modules[] = $this->bean->{$link}->getRelatedModuleName(); } } } return $subpanel_modules; }
public function setUp() { SugarTestHelper::setUp('beanFiles'); SugarTestHelper::setUp('beanList'); SugarTestHelper::setUp('current_user'); $this->account = SugarTestAccountUtilities::createAccount(); $this->contact = SugarTestContactUtilities::createContact(); $this->email = SugarTestEmailUtilities::createEmail(); $this->opportunity = SugarTestOpportunityUtilities::createOpportunity('', $this->account); $this->contact->account_id = $this->account->id; $this->contact->save(); $this->opportunity->load_relationship('contacts'); $this->opportunity->contacts->add($this->contact); $this->email->parent_id = $this->contact->id; $this->email->parent_type = $this->contact->module_name; $this->email->save(); if (isset($GLOBALS['app'])) { $this->application = $GLOBALS['app']; } $GLOBALS['app'] = new SugarApplication(); $GLOBALS['app']->controller = new SugarController(); }
/** * Take any Billing and Shipping Contacts and link the to the Opportunity * * @param Quote $quote * @param Opportunity $opp */ protected function linkQuoteContactsToOpportunity(Quote $quote, Opportunity $opp) { // @codeCoverageIgnoreStart global $app_list_strings; // @codeCoverageIgnoreEnd //opportunity_relationship_type_dom $quote->load_relationship('shipping_contacts'); $quote->load_relationship('billing_contacts'); $ids = array_merge($quote->shipping_contacts->get(), $quote->billing_contacts->get()); $ids = array_unique($ids); $default_role = isset($app_list_strings['opportunity_relationship_type_dom']['Other']) ? 'Other' : ''; if (!empty($ids)) { $opp->load_relationship('contacts'); foreach ($ids as $id) { $opp->contacts->add($id, array('contact_role' => $default_role)); } } }
if (empty($contact->last_name)) { $contact->last_name = $contact_last_name; } if (empty($contact->mobile)) { $contact->mobile = $contact_mobile; } if (empty($contact->assigned_user_id)) { $contact->assigned_user_id = 1; } $contact->save(); } else { $contact->first_name = $contact_first_name; $contact->last_name = $contact_last_name; $contact->email1 = $contact_email; $contact->mobile = $contact_mobile; $contact->assigned_user_id = 1; $contact->save(); $contact->load_relationship('accounts'); $contact->accounts->add($account->id); } // Create the Opportunity $opportunity = new Opportunity(); $opportunity->name = $opportunity_name; $opportunity->amount = $opportunity_amount; $opportunity->date_closed = $timeDate->getNow(true)->asDbDate(); $opportunity->sales_stage = "Closed Won"; $opportunity->account_id = $account->id; $opportunity->assigned_user_id = 1; $opportunity->save(); $opportunity->load_relationship('contacts'); $opportunity->contacts->add($contact->id);