本文整理汇总了PHP中Opportunity::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Opportunity::save方法的具体用法?PHP Opportunity::save怎么用?PHP Opportunity::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opportunity
的用法示例。
在下文中一共展示了Opportunity::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* Creates a temporary opportunity
*/
public function setUp()
{
$GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
$this->opportunity = new Opportunity();
$this->opportunity->currency_id = -99;
$this->opportunity->save();
}
示例2: actionLoadOpportunitiesSampler
public function actionLoadOpportunitiesSampler()
{
if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
throw new NotSupportedException();
}
for ($i = 0; $i < 11; $i++) {
$owner = Yii::app()->user->userModel;
$name = 'Mass Delete ' . $i;
$currencies = Currency::getAll();
$currencyValue = new CurrencyValue();
$currencyValue->value = 500.54;
$currencyValue->currency = $currencies[0];
$opportunity = new Opportunity();
$opportunity->owner = $owner;
$opportunity->name = $name;
$opportunity->amount = $currencyValue;
$opportunity->closeDate = '2011-01-01';
//eventually fix to make correct format
$opportunity->stage->value = 'Negotiating';
$saved = $opportunity->save();
if (!$saved) {
throw new NotSupportedException();
}
}
}
示例3: create
function create(&$bean)
{
if ($bean->code_inc == '') {
$relate_field = "contact_id";
$opportunity = new Opportunity();
$opportunity->name = "Сделка с клиентом " . $bean->last_name . " " . $bean->first_name . " от " . date("d.m.Y");
$opportunity->{$relate_field} = $bean->id;
$opportunity->assigned_user_id = $bean->assigned_user_id;
$opportunity->type_of_realty = "client";
$opportunity->save();
}
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
UserTestHelper::createBasicUser('jim');
AllPermissionsOptimizationUtil::rebuild();
OpportunityTestHelper::createOpportunityStagesIfDoesNotExist();
OpportunityTestHelper::createOpportunitySourcesIfDoesNotExist();
$currencies = Currency::getAll();
//Make opportunities for testing chart data.
$currencyValue = new CurrencyValue();
$currencyValue->value = 200;
$currencyValue->currency = $currencies[0];
$opportunity = new Opportunity();
$opportunity->owner = $super;
$opportunity->name = 'abc1';
$opportunity->amount = $currencyValue;
$opportunity->closeDate = '2011-01-01';
$opportunity->stage->value = 'Negotiating';
$opportunity->source->value = 'Outbound';
assert($opportunity->save());
// Not Coding Standard
$currencyValue = new CurrencyValue();
$currencyValue->value = 350;
$currencyValue->currency = $currencies[0];
$opportunity = new Opportunity();
$opportunity->owner = $super;
$opportunity->name = 'abc2';
$opportunity->amount = $currencyValue;
$opportunity->closeDate = '2011-01-01';
$opportunity->stage->value = 'Negotiating';
$opportunity->source->value = 'Trade Show';
assert($opportunity->save());
// Not Coding Standard
$currencyValue = new CurrencyValue();
$currencyValue->value = 100;
$currencyValue->currency = $currencies[0];
$opportunity = new Opportunity();
$opportunity->owner = $super;
$opportunity->name = 'abc2';
$opportunity->amount = $currencyValue;
$opportunity->closeDate = '2011-01-01';
$opportunity->stage->value = 'Verbal';
$opportunity->source->value = 'Trade Show';
assert($opportunity->save());
// Not Coding Standard
}
示例5: populateSeedDataForSearchTest
function populateSeedDataForSearchTest($user_id)
{
$results = array();
$a1_id = create_guid();
$a1 = new Account();
$a1->id = $a1_id;
$a1->new_with_id = TRUE;
$a1->name = "UNIT TEST {$a1_id}";
$a1->assigned_user_id = $user_id;
$a1->save();
$results[] = array('id' => $a1_id, 'fieldName' => 'name', 'fieldValue' => "UNIT TEST {$a1_id}");
$a2_id = create_guid();
$a2 = new Account();
$a2->new_with_id = TRUE;
$a2->id = $a2_id;
$a2->name = "UNIT TEST {$a2_id}";
$a2->assigned_user_id = 'unittest';
$a2->save();
$results[] = array('id' => $a2_id, 'fieldName' => 'name', 'fieldValue' => "UNIT TEST {$a2_id}");
$c1_id = create_guid();
$c1 = new Contact();
$c1->id = $c1_id;
$c1->new_with_id = TRUE;
$c1->first_name = "UNIT TEST";
$c1->last_name = "UNIT_TEST";
$c1->assigned_user_id = $user_id;
$c1->save();
$results[] = array('id' => $c1_id, 'fieldName' => 'name', 'fieldValue' => $c1->first_name . ' ' . $c1->last_name);
$op1_id = create_guid();
$op1 = new Opportunity();
$op1->new_with_id = TRUE;
$op1->id = $op1_id;
$op1->name = "UNIT TEST {$op1_id}";
$op1->assigned_user_id = $user_id;
$op1->save();
$results[] = array('id' => $op1_id, 'fieldName' => 'name', 'fieldValue' => "UNIT TEST {$op1_id}");
$op2_id = create_guid();
$op2 = new Opportunity();
$op2->new_with_id = TRUE;
$op2->id = $op2_id;
$op2->name = "UNIT TEST {$op2_id}";
$op2->assigned_user_id = 'unittest';
$op2->save();
$results[] = array('id' => $op2_id, 'fieldName' => 'name', 'fieldValue' => "UNIT TEST {$op2_id}");
$GLOBALS['db']->commit();
return $results;
}
示例6: _createOpportunity
private function _createOpportunity($id, $time, $account)
{
global $timedate;
$name = 'SugarOpportunity';
$opportunity = new Opportunity();
if (!empty($id)) {
$opportunity->new_with_id = true;
$opportunity->id = $id;
}
$opportunity->name = $name . $time;
$opportunity->amount = 10000;
$opportunity->account_id = $account->id;
$opportunity->account_name = $account->name;
$opportunity->date_closed = $timedate->to_display_date_time(gmdate("Y-m-d H:i:s"));
$opportunity->save();
$GLOBALS['db']->commit();
self::$_createdOpportunities[] = $opportunity;
return $opportunity;
}
示例7: CreateCrossSellingOpportunities
function CreateCrossSellingOpportunities($bean)
{
if ($bean->fetched_row['name'] !== $bean->name && $bean->name === "Product/Service A") {
$opportunity = new Opportunity();
$opportunity->name = "Product/Service B";
$opportunity->account_id = $bean->account_id;
$opportunity->sales_stage = "Prospecting";
$opportunity->assigned_user_id = $bean->assigned_user_id;
$opportunity->save();
SugarApplication::appendErrorMessage('You have a new Opportunity for Cross Selling Opportunity');
}
}
示例8: create_opportunity
function create_opportunity($user_name, $password, $name, $amount)
{
if (!validate_user($user_name, $password)) {
return 0;
}
$seed_user = new User();
$user_id = $seed_user->retrieve_user_id($user_name);
$opp = new Opportunity();
if (!$opp->ACLAccess('Save')) {
return -1;
}
$opp->name = $name;
$opp->amount = $amount;
$opp->assigned_user_id = $user_id;
$opp->assigned_user_name = $user_name;
return $opp->save();
}
示例9: Opportunity
if (!$testrun) {
$opp = new Opportunity($db, 0, $locid, $client->uid, $client->acct);
$opp->o_city = addslashes($job->city);
$opp->o_state = addslashes($job->state);
$opp->o_zip = $zip;
$opp->specialty = $spec;
$opp->o_facility = htmlspecialchars(strip_tags($title));
$opp->description = $descr;
$opp->o_name = $jid;
$opp->o_email = addslashes($client->email);
$opp->o_phone = addslashes($client->phone);
$opp->o_fax = preg_replace('/[^0-9]/', '', $client->fax);
$opp->o_title = addslashes($client->title);
$opp->o_contact = addslashes($client->firstname . " " . $client->lastname);
$progress .= ' creating...';
$opp->save();
$sql = "insert into importrac (jobid,jobacct,jobflag,jobopp) VALUES ('{$jid}',{$client->acct},0,{$opp->id}) ON DUPLICATE KEY UPDATE jobflag=0";
$db->query($sql);
}
// testrun
}
// dup check
$progress .= ' Done!<br>';
} catch (Exception $e) {
if ($testrun) {
$progress .= " TEST FAILED: " . $e->getMessage() . ' (' . $e->getCode() . ')<br>';
$mesg = "Errors detected: see below";
$result = 0;
} else {
$progress .= " PROBLEM RECORD: " . $e->getMessage() . ' (' . $e->getCode() . ')<br>';
$mesg = "Errors detected: see below";
示例10: Opportunity
function update_tilkee_project_API(&$bean, $event, $arguments = null)
{
if ($event != 'after_save') {
return;
}
global $beanFiles;
// Update linked Opportunity sales_stage if project archived
if ($bean->status == 'archived' && !empty($bean->opportunities_id)) {
if (file_exists($beanFiles['Opportunity'])) {
require_once $beanFiles['Opportunity'];
$current_opportunity = new Opportunity();
$current_opportunity->retrieve($bean->opportunities_id);
if ($bean->won == 'true') {
if ($current_opportunity->sales_stage != 'Closed Won') {
$current_opportunity->sales_stage = 'Closed Won';
$current_opportunity->save();
}
}
if ($bean->won == 'false') {
if ($current_opportunity->sales_stage != 'Closed Lost') {
$current_opportunity->sales_stage = 'Closed Lost';
$current_opportunity->save();
}
}
}
}
// If the project just create
if (empty($bean->tilkee_id)) {
// appel de l'API de creation du projet et Mise a jour des infos du projet
$bean->create_from_API();
//} else {
// appel de l'API de mise à jour du projet et Mise a jour des infos du projet
//$bean->update_from_API($this->won, ($this->status=='archived')?'true':'false');
}
}
示例11: testSetStageAndSourceAndRetrieveDisplayName
/**
* @depends testCreateAndGetOpportunityById
*/
public function testSetStageAndSourceAndRetrieveDisplayName()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = User::getByUsername('billy');
$stageValues = array('Prospecting', 'Negotiating', 'Closed Won');
$stageFieldData = CustomFieldData::getByName('SalesStages');
$stageFieldData->serializedData = serialize($stageValues);
$this->assertTrue($stageFieldData->save());
$sourceValues = array('Word of Mouth', 'Outbound', 'Trade Show');
$sourceFieldData = CustomFieldData::getByName('LeadSources');
$sourceFieldData->serializedData = serialize($sourceValues);
$this->assertTrue($sourceFieldData->save());
$currencies = Currency::getAll();
$currencyValue = new CurrencyValue();
$currencyValue->value = 500.54;
$currencyValue->currency = $currencies[0];
$opportunity = new Opportunity();
$opportunity->owner = $user;
$opportunity->name = '1000 Widgets';
$opportunity->amount = $currencyValue;
$opportunity->closeDate = '2011-01-01';
//eventually fix to make correct format
$opportunity->stage->value = $stageValues[1];
$opportunity->source->value = $sourceValues[1];
$saved = $opportunity->save();
$this->assertTrue($saved);
$this->assertTrue($opportunity->id !== null);
$id = $opportunity->id;
unset($opportunity);
$opportunity = Opportunity::getById($id);
$this->assertEquals('Negotiating', $opportunity->stage->value);
$this->assertEquals('Outbound', $opportunity->source->value);
$this->assertEquals(1, $currencies[0]->rateToBase);
}
示例12: testGetGlobalSearchResultsByPartialTerm
/**
* @depends testGetByPartialName
*/
public function testGetGlobalSearchResultsByPartialTerm()
{
//Unfrozen, there are too many attributes that have to be columns in the database at this point, so
//now this is just a frozen test.
if (RedBeanDatabase::isFrozen()) {
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
//Add an account with an email address.
$account = new Account();
$account->name = 'The Zoo';
$account->owner = $super;
$email = new Email();
$email->optOut = 0;
$email->emailAddress = 'animal@zoo.com';
$account->primaryEmail = $email;
$this->assertTrue($account->save());
//Create a contact with a similar e-mail address
$contactStates = ContactState::getAll();
$contact = new Contact();
$contact->title->value = 'Mr.';
$contact->firstName = 'Big';
$contact->lastName = 'Elephant';
$contact->owner = $super;
$contact->state = $contactStates[count($contactStates) - 1];
$email = new Email();
$email->optOut = 0;
$email->emailAddress = 'animal@africa.com';
$contact->primaryEmail = $email;
$this->assertTrue($contact->save());
//Add an opportunity
$currencies = Currency::getAll();
$currencyValue = new CurrencyValue();
$currencyValue->value = 500.54;
$currencyValue->currency = $currencies[0];
$opportunity = new Opportunity();
$opportunity->owner = $super;
$opportunity->name = 'Animal Crackers';
$opportunity->amount = $currencyValue;
$opportunity->closeDate = '2011-01-01';
//eventually fix to make correct format
$opportunity->stage->value = 'Negotiating';
$this->assertTrue($opportunity->save());
//Test where no results are expected.
$data = ModelAutoCompleteUtil::getGlobalSearchResultsByPartialTerm('weqqw', 5, $super);
$this->assertEquals(array(array('href' => '', 'label' => 'No Results Found', 'iconClass' => '')), $data);
//Test where one account is expected searching by account name.
$data = ModelAutoCompleteUtil::getGlobalSearchResultsByPartialTerm('Rabbit', 5, $super);
$this->assertEquals(1, count($data));
$this->assertEquals('Rabbit Systems', $data[0]['label']);
//test anyEmail where results are across more than one module. This will also pick up an opportunity that
//has the name 'animal' in it.
$data = ModelAutoCompleteUtil::getGlobalSearchResultsByPartialTerm('animal', 5, $super);
$this->assertEquals(3, count($data));
$this->assertEquals('The Zoo', $data[0]['label']);
$this->assertEquals('Big Elephant', $data[1]['label']);
$this->assertEquals('Animal Crackers', $data[2]['label']);
}
}
示例13: testsave
public function testsave()
{
$opportunity = new Opportunity();
$opportunity->name = 'test';
$opportunity->description = 'test description';
$opportunity->sales_stage = 'Value Proposition';
$result = $opportunity->save();
//test for record ID to verify that record is saved
$this->assertTrue(isset($opportunity->id));
$this->assertEquals(36, strlen($opportunity->id));
$this->assertEquals(-99, $opportunity->currency_id);
$this->assertEquals(30, $opportunity->probability);
//mark the record as deleted and verify that this record cannot be retrieved anymore.
$opportunity->mark_deleted($opportunity->id);
$result = $opportunity->retrieve($opportunity->id);
$this->assertEquals(null, $result);
}
示例14: testIsCurrencyInUseByIdAndChangRateIfValueChangesOrCurrencyChanges
/**
* @depends testConstructDerivedWithUserDefaultCurrency
*/
public function testIsCurrencyInUseByIdAndChangRateIfValueChangesOrCurrencyChanges()
{
$currencyHelper = Yii::app()->currencyHelper;
$euro = Currency::getByCode('EUR');
$this->assertFalse(CurrencyValue::isCurrencyInUseById($euro->id));
$opportunity = new Opportunity();
$opportunity->name = 'Tyfe';
$opportunity->stage->value = 'Starting Up';
$opportunity->closeDate = '2008-10-05';
$opportunity->amount->value = 456.78;
$opportunity->amount->currency = $euro;
$this->assertTrue($opportunity->save());
$this->assertEquals(1.5, $opportunity->amount->rateToBase);
$this->assertTrue(CurrencyValue::isCurrencyInUseById($euro->id));
//change the currency rate for the euro.
$euro->rateToBase = 3;
$this->assertTrue($euro->save());
//Now test saving the opportunity again but not changing the amount value. The rate should stay the same.
$id = $opportunity->id;
unset($opportunity);
$opportunity = Opportunity::getById($id);
$this->assertEquals(456.78, $opportunity->amount->value);
$opportunity->amount->value = 456.78;
$this->assertTrue($opportunity->save());
$this->assertEquals(456.78, $opportunity->amount->value);
$this->assertEquals(1.5, $opportunity->amount->rateToBase);
//Now change amount. the exchange rate should change.
$opportunity->amount->value = 566.0;
$this->assertTrue($opportunity->save());
$this->assertEquals(3, $opportunity->amount->rateToBase);
//Now change the currency only. should change rate.
$id = $opportunity->id;
unset($opportunity);
$opportunity = Opportunity::getById($id);
$opportunity->amount->currency = Currency::getByCode('USD');
$this->assertTrue($opportunity->save());
$this->assertEquals(1, $opportunity->amount->rateToBase);
}
示例15: mapQuoteToOpportunity
/**
* Maps Quote Values to the Opportunity
*
* @param Quote $quote
* @param Opportunity $opp
*/
protected function mapQuoteToOpportunity(Quote $quote, Opportunity $opp)
{
// @codeCoverageIgnoreStart
global $app_list_strings;
// @codeCoverageIgnoreEnd
$forecastConfig = $this->getForecastConfig();
$opp->id = create_guid();
$opp->new_with_id = true;
$opp->assigned_user_id = $quote->assigned_user_id;
$opp->date_closed = $quote->date_quote_expected_closed;
$opp->name = $quote->name;
$opp->assigned_user_name = $quote->assigned_user_name;
$opp->lead_source = isset($app_list_strings['lead_source_dom']['Self Generated']) ? 'Self Generated' : null;
$opp->opportunity_type = isset($app_list_strings['opportunity_type_dom']['New Business']) ? $app_list_strings['opportunity_type_dom']['New Business'] : null;
$opp->team_id = $quote->team_id;
// TODO: this will need to change when we have the switch for Opportunities,
// TODO: but since that is not done yet this will use the forecast_by.
if ($forecastConfig['forecast_by'] == 'Opportunities') {
// just setting sales_stage will now set probability correctly
$opp->sales_stage = isset($app_list_strings['sales_stage_dom']['Proposal/Price Quote']) ? 'Proposal/Price Quote' : null;
$opp->amount = $quote->total;
}
$opp->quote_id = $quote->id;
$opp->currency_id = $quote->currency_id;
$opp->base_rate = $quote->base_rate;
$opp->account_id = $quote->billing_account_id;
// save the opp so we can add the products to it.
$opp->save();
}