本文整理汇总了PHP中Opportunity::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Opportunity::getById方法的具体用法?PHP Opportunity::getById怎么用?PHP Opportunity::getById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opportunity
的用法示例。
在下文中一共展示了Opportunity::getById方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testForgettingAModelWithAddingAManyToManyRelation
public function testForgettingAModelWithAddingAManyToManyRelation()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
//Setup test data owned by the super user.
$account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
$contact = ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
$contactId = $contact->id;
OpportunityTestHelper::createOpportunityStagesIfDoesNotExist();
$opportunity = OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp', $super, $account);
$opportunityId = $opportunity->id;
//Model forgets ok.
$contact->forget();
$contact = Contact::getById($contactId);
$opportunity->contacts->add($contact);
$opportunity->save();
//Still forgets ok, because we are forgetting both opportunity and contact. If we forget just contact,
//it would break later when you try to look at $contact->oppportunities or $opportunity->contacts
$contact->forget();
$opportunity->forget();
$contact = Contact::getById($contactId);
$opportunity = Opportunity::getById($opportunityId);
//Finds many-to-many relationships ok on both sides
$this->assertEquals(1, $opportunity->contacts->count());
$this->assertEquals(1, $contact->opportunities->count());
$this->assertEquals($opportunity, $contact->opportunities[0]);
$this->assertEquals($contact, $opportunity->contacts[0]);
}
示例2: actionCopy
public function actionCopy($id)
{
$copyToOpportunity = new Opportunity();
$postVariableName = get_class($copyToOpportunity);
if (!isset($_POST[$postVariableName])) {
$opportunity = Opportunity::getById((int) $id);
ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($opportunity);
ZurmoCopyModelUtil::copy($opportunity, $copyToOpportunity);
}
$this->processEdit($copyToOpportunity);
}
示例3: testSuperUserAllDefaultControllerActions
public function testSuperUserAllDefaultControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Test all default controller actions that do not require any POST/GET variables to be passed.
//This does not include portlet controller actions.
$this->runControllerWithNoExceptionsAndGetContent('opportunities/default');
$this->runControllerWithNoExceptionsAndGetContent('opportunities/default/index');
$this->runControllerWithNoExceptionsAndGetContent('opportunities/default/create');
$content = $this->runControllerWithNoExceptionsAndGetContent('opportunities/default/list');
$this->assertFalse(strpos($content, 'anyMixedAttributes') === false);
//Test the search or paging of the listview.
Yii::app()->clientScript->reset();
//to make sure old js doesn't make it to the UI
$this->setGetArray(array('ajax' => 'list-view'));
$content = $this->runControllerWithNoExceptionsAndGetContent('opportunities/default/list');
$this->assertTrue(strpos($content, 'anyMixedAttributes') === false);
$this->resetGetArray();
//Default Controller actions requiring some sort of parameter via POST or GET
//Load Model Edit Views
$opportunities = Opportunity::getAll();
$this->assertEquals(12, count($opportunities));
$superOpportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpp');
$superOpportunityId2 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp2');
$superOpportunityId3 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp3');
$superOpportunityId4 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp4');
$superOpportunityId5 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp5');
$superOpportunityId6 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp6');
$superOpportunityId7 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp7');
$superOpportunityId8 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp8');
$superOpportunityId9 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp9');
$superOpportunityId10 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp10');
$superOpportunityId11 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp11');
$superOpportunityId12 = self::getModelIdByModelNameAndName('Opportunity', 'superOpp12');
$this->setGetArray(array('id' => $superOpportunityId));
$this->runControllerWithNoExceptionsAndGetContent('opportunities/default/edit');
//Save opportunity.
$superOpportunity = Opportunity::getById($superOpportunityId);
$this->assertEquals(null, $superOpportunity->description);
$this->setPostArray(array('Opportunity' => array('description' => '456765421')));
$this->runControllerWithRedirectExceptionAndGetContent('opportunities/default/edit');
$superOpportunity = Opportunity::getById($superOpportunityId);
$this->assertEquals('456765421', $superOpportunity->description);
//Test having a failed validation on the opportunity during save.
$this->setGetArray(array('id' => $superOpportunityId));
$this->setPostArray(array('Opportunity' => array('name' => '')));
$content = $this->runControllerWithNoExceptionsAndGetContent('opportunities/default/edit');
$this->assertFalse(strpos($content, 'Name cannot be blank') === false);
//Load Model Detail Views
$this->setGetArray(array('id' => $superOpportunityId));
$this->resetPostArray();
$this->runControllerWithNoExceptionsAndGetContent('opportunities/default/details');
//Load Model MassEdit Views.
//MassEdit view for single selected ids
$this->setGetArray(array('selectedIds' => '4,5,6,7,8,9', 'selectAll' => ''));
// Not Coding Standard
$this->resetPostArray();
$content = $this->runControllerWithNoExceptionsAndGetContent('opportunities/default/massEdit');
$this->assertFalse(strpos($content, '<strong>6</strong> records selected for updating') === false);
//MassEdit view for all result selected ids
$this->setGetArray(array('selectAll' => '1'));
$this->resetPostArray();
$content = $this->runControllerWithNoExceptionsAndGetContent('opportunities/default/massEdit');
$this->assertFalse(strpos($content, '<strong>12</strong> records selected for updating') === false);
//save Model MassEdit for selected Ids
//Test that the 2 contacts do not have the office phone number we are populating them with.
$opportunity1 = Opportunity::getById($superOpportunityId);
$opportunity2 = Opportunity::getById($superOpportunityId2);
$opportunity3 = Opportunity::getById($superOpportunityId3);
$opportunity4 = Opportunity::getById($superOpportunityId4);
$this->assertNotEquals('7788', $opportunity1->description);
$this->assertNotEquals('7788', $opportunity2->description);
$this->assertNotEquals('7788', $opportunity3->description);
$this->assertNotEquals('7788', $opportunity4->description);
$this->setGetArray(array('selectedIds' => $superOpportunityId . ',' . $superOpportunityId2, 'selectAll' => '', 'Opportunity_page' => 1));
$this->setPostArray(array('Opportunity' => array('description' => '7788'), 'MassEdit' => array('description' => 1)));
$pageSize = Yii::app()->pagination->getForCurrentUserByType('massEditProgressPageSize');
$this->assertEquals(5, $pageSize);
Yii::app()->pagination->setForCurrentUserByType('massEditProgressPageSize', 20);
$this->runControllerWithRedirectExceptionAndGetContent('opportunities/default/massEdit');
Yii::app()->pagination->setForCurrentUserByType('massEditProgressPageSize', $pageSize);
//Test that the 2 opportunities have the new office phone number and the other contacts do not.
$opportunity1 = Opportunity::getById($superOpportunityId);
$opportunity2 = Opportunity::getById($superOpportunityId2);
$opportunity3 = Opportunity::getById($superOpportunityId3);
$opportunity4 = Opportunity::getById($superOpportunityId4);
$opportunity5 = Opportunity::getById($superOpportunityId5);
$opportunity6 = Opportunity::getById($superOpportunityId6);
$opportunity7 = Opportunity::getById($superOpportunityId7);
$opportunity8 = Opportunity::getById($superOpportunityId8);
$opportunity9 = Opportunity::getById($superOpportunityId9);
$opportunity10 = Opportunity::getById($superOpportunityId10);
$opportunity11 = Opportunity::getById($superOpportunityId11);
$opportunity12 = Opportunity::getById($superOpportunityId12);
$this->assertEquals('7788', $opportunity1->description);
$this->assertEquals('7788', $opportunity2->description);
$this->assertNotEquals('7788', $opportunity3->description);
$this->assertNotEquals('7788', $opportunity4->description);
$this->assertNotEquals('7788', $opportunity5->description);
$this->assertNotEquals('7788', $opportunity6->description);
$this->assertNotEquals('7788', $opportunity7->description);
//.........这里部分代码省略.........
示例4: testEditOfTheOpportunityForTheCustomFieldsPlacedForOpportunitiesModule
/**
* @depends testEditOfTheOpportunityForTheTagCloudFieldAfterRemovingAllTagsPlacedForOpportunitiesModule
*/
public function testEditOfTheOpportunityForTheCustomFieldsPlacedForOpportunitiesModule()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Set the date and datetime variable values here.
$date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
$dateAssert = date('Y-m-d');
$datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
$datetimeAssert = date('Y-m-d H:i:') . "00";
$baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
//Retrieve the account id, the super user id and opportunity Id.
$accountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
$superUserId = $super->id;
$explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
$opportunity = Opportunity::getByName('myEditOpportunity');
$opportunityId = $opportunity[0]->id;
//Edit a new Opportunity based on the custom fields.
$this->setGetArray(array('id' => $opportunityId));
$this->setPostArray(array('Opportunity' => array('name' => 'myEditOpportunity', 'amount' => array('value' => 288000, 'currency' => array('id' => $baseCurrency->id)), 'account' => array('id' => $accountId), 'closeDate' => $date, 'stage' => array('value' => 'Qualification'), 'source' => array('value' => 'Inbound Call'), 'description' => 'This is the Edit Description', 'owner' => array('id' => $superUserId), 'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission), 'checkboxCstm' => '0', 'currencyCstm' => array('value' => 40, 'currency' => array('id' => $baseCurrency->id)), 'decimalCstm' => '12', 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'picklistCstm' => array('value' => 'b'), 'multiselectCstm' => array('values' => array('gg', 'hh')), 'tagcloudCstm' => array('values' => array('reading', 'surfing')), 'countrylistCstm' => array('value' => 'aaaa'), 'statelistCstm' => array('value' => 'aaa1'), 'citylistCstm' => array('value' => 'ab1'), 'integerCstm' => '11', 'phoneCstm' => '259-784-2069', 'radioCstm' => array('value' => 'e'), 'textCstm' => 'This is a test Edit Text', 'textareaCstm' => 'This is a test Edit TextArea', 'urlCstm' => 'http://wwww.abc-edit.com')));
$this->runControllerWithRedirectExceptionAndGetUrl('opportunities/default/edit');
//Check the details if they are saved properly for the custom fields.
$opportunityId = self::getModelIdByModelNameAndName('Opportunity', 'myEditOpportunity');
$opportunity = Opportunity::getById($opportunityId);
//Retrieve the permission of the opportunity.
$explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($opportunity);
$readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
$readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
$this->assertEquals($opportunity->name, 'myEditOpportunity');
$this->assertEquals($opportunity->amount->value, '288000');
$this->assertEquals($opportunity->amount->currency->id, $baseCurrency->id);
$this->assertEquals($opportunity->account->id, $accountId);
$this->assertEquals($opportunity->probability, '25');
$this->assertEquals($opportunity->stage->value, 'Qualification');
$this->assertEquals($opportunity->source->value, 'Inbound Call');
$this->assertEquals($opportunity->description, 'This is the Edit Description');
$this->assertEquals($opportunity->owner->id, $superUserId);
$this->assertEquals(1, count($readWritePermitables));
$this->assertEquals(0, count($readOnlyPermitables));
$this->assertEquals($opportunity->checkboxCstm, '0');
$this->assertEquals($opportunity->currencyCstm->value, 40);
$this->assertEquals($opportunity->currencyCstm->currency->id, $baseCurrency->id);
$this->assertEquals($opportunity->dateCstm, $dateAssert);
$this->assertEquals($opportunity->datetimeCstm, $datetimeAssert);
$this->assertEquals($opportunity->decimalCstm, '12');
$this->assertEquals($opportunity->picklistCstm->value, 'b');
$this->assertEquals($opportunity->integerCstm, 11);
$this->assertEquals($opportunity->phoneCstm, '259-784-2069');
$this->assertEquals($opportunity->radioCstm->value, 'e');
$this->assertEquals($opportunity->textCstm, 'This is a test Edit Text');
$this->assertEquals($opportunity->textareaCstm, 'This is a test Edit TextArea');
$this->assertEquals($opportunity->urlCstm, 'http://wwww.abc-edit.com');
$this->assertEquals($opportunity->dateCstm, $dateAssert);
$this->assertEquals($opportunity->datetimeCstm, $datetimeAssert);
$this->assertEquals($opportunity->countrylistCstm->value, 'aaaa');
$this->assertEquals($opportunity->statelistCstm->value, 'aaa1');
$this->assertEquals($opportunity->citylistCstm->value, 'ab1');
$this->assertContains('gg', $opportunity->multiselectCstm->values);
$this->assertContains('hh', $opportunity->multiselectCstm->values);
$this->assertContains('reading', $opportunity->tagcloudCstm->values);
$this->assertContains('surfing', $opportunity->tagcloudCstm->values);
$metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('calcnumber', 'Opportunity');
$testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $opportunity);
$this->assertEquals(132, $testCalculatedValue);
}
开发者ID:KulturedKitsch,项目名称:kulturedkitsch.info,代码行数:66,代码来源:OpportunitiesDesignerSuperUserWalkthroughTest.php
示例5: 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);
}
示例6: 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);
}
示例7: testUpdateWithRelations
/**
* @depends testCreateWithRelations
*/
public function testUpdateWithRelations()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
$contact = ContactTestHelper::createContactByNameForOwner('Simon', $super);
$opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('My Opportunity', $super);
$compareData = $this->getModelToApiDataUtilData($contact);
$contact->forget();
$data['modelRelations'] = array('opportunities' => array(array('action' => 'add', 'modelId' => $opportunity->id, 'modelClassName' => 'Opportunity')));
$data['firstName'] = 'Fred';
$response = $this->createApiCallWithRelativeUrl('update/' . $compareData['id'], 'PUT', $headers, array('data' => $data));
$response = json_decode($response, true);
unset($response['data']['modifiedDateTime']);
unset($compareData['modifiedDateTime']);
$compareData['firstName'] = 'Fred';
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals($compareData, $response['data']);
RedBeanModel::forgetAll();
$contact = Contact::getById($compareData['id']);
$this->assertEquals(1, count($contact->opportunities));
$this->assertEquals($opportunity->id, $contact->opportunities[0]->id);
$opportunity = Opportunity::getById($opportunity->id);
$this->assertEquals(1, count($opportunity->contacts));
$this->assertEquals($contact->id, $opportunity->contacts[0]->id);
// Now test remove relations
$data['modelRelations'] = array('opportunities' => array(array('action' => 'remove', 'modelId' => $opportunity->id, 'modelClassName' => 'Opportunity')));
$response = $this->createApiCallWithRelativeUrl('update/' . $compareData['id'], 'PUT', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
RedBeanModel::forgetAll();
$contact = Contact::getById($compareData['id']);
$this->assertEquals(0, count($contact->opportunities));
$opportunity = Opportunity::getById($opportunity->id);
$this->assertEquals(0, count($opportunity->contacts));
}
示例8: actionEdit
public function actionEdit($id, $redirectUrl = null)
{
$contract = Contract::getById(intval($id));
$sql = "select * from contract_opportunity where contract_id=" . $id;
$rec = Yii::app()->db->createCommand($sql)->queryRow();
$rec_t['value'] = $rec_c['value'] = '';
if (!empty($rec) && !empty($rec['opportunity_id'])) {
$getopportunity = Opportunity::getById(intval($rec['opportunity_id']));
$sql1 = "select * from opportunity where id=" . $rec['opportunity_id'];
$rec1 = Yii::app()->db->createCommand($sql1)->queryRow();
}
if (isset($rec1['totalbulkpricstm_currencyvalue_id']) && !empty($rec1['totalbulkpricstm_currencyvalue_id'])) {
//get totalbuilprice
$sql_t = "select * from currencyvalue where id=" . $rec1['totalbulkpricstm_currencyvalue_id'];
$rec_t = Yii::app()->db->createCommand($sql_t)->queryRow();
}
if (isset($rec1['constructcoscstm_currencyvalue_id']) && !empty($rec1['constructcoscstm_currencyvalue_id'])) {
$sql_c = "select * from currencyvalue where id=" . $rec1['constructcoscstm_currencyvalue_id'];
$rec_c = Yii::app()->db->createCommand($sql_c)->queryRow();
}
$getaccount = Account::getById(intval($getopportunity->account->id));
$_SESSION['unitsCstmCstm'] = !empty($getaccount->unitsCstmCstm) ? $getaccount->unitsCstmCstm : 1;
$_SESSION['totalbulkpricstm'] = !empty($rec_t['value']) ? $rec_t['value'] : 1;
$_SESSION['totalcostprccstm'] = !empty($rec_c['value']) ? $_SESSION['unitsCstmCstm'] * $rec_c['value'] : $_SESSION['unitsCstmCstm'] * 1;
ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contract);
$this->processEdit($contract, $redirectUrl);
}
示例9: resolveProjectManyManyOpportunitiesFromPost
/**
* Resolves the opportunities sent via post request
* @param Project $project
* @param array $postData
* @return array containing opportunities
*/
public static function resolveProjectManyManyOpportunitiesFromPost(Project $project, $postData)
{
assert('$project instanceof Project');
$newOpportunity = array();
if (isset($postData['opportunityIds']) && strlen($postData['opportunityIds']) > 0) {
$opportunityIds = explode(",", $postData['opportunityIds']);
// Not Coding Standard
foreach ($opportunityIds as $opportunityId) {
$newOpportunity[$opportunityId] = Opportunity::getById((int) $opportunityId);
}
if ($project->opportunities->count() > 0) {
$project->opportunities->removeAll();
}
//Now add missing contacts
foreach ($newOpportunity as $opportunity) {
$project->opportunities->add($opportunity);
}
} else {
//remove all opportunities
$project->opportunities->removeAll();
}
return $newOpportunity;
}
示例10: makeOpportunityProductSelection
public function makeOpportunityProductSelection($datas, $opportunityId)
{
$content = '';
$opptProducts = OpportunityProduct::getAllByOpptId(intval($opportunityId));
$opportunity = Opportunity::getById($opportunityId);
$count = count($opptProducts);
$totalDirectCost = 0;
$totalMH = 0;
$suggestedPrice = 0;
$opptPdctMap;
if (count($opptProducts) > 0) {
foreach ($opptProducts as $row) {
$opptPdctMap[$row->Category][] = $row;
}
$tableCreation = '';
$tableCreation .= '<div class="view-toolbar-container clearfix">
<div style="background-color:#E0D1D1; color:black;padding:0.5%; font-weight:bold; font-size: 13px;">
Estimate Summary
</div>
<div style="font-weight: bold; padding: 10px;">Number Of Products :' . $count . '</div>';
$tableCreation .= '<table border="1" width="100%" class="items">
<colgroup span="5"></colgroup>';
$tableCreation .= '<thead style="font-weight: bold; background-color:#E6E6E6; color: black;padding: 5px;">
<tr style="border: 1px solid gray;">
<th colspan="13" style="font-weight: bold;padding: 10px;text-align:center;">Opportunity Products</th>
</tr>
<th style="font-weight: bold;padding: 10px;text-align:center;">Product Code</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">Product Name</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">Unit of Measure</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">Quantity</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">Frequency</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">MH</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">L</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">B</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">M</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">E</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">S</th>
<th style="font-weight: bold;padding: 10px;text-align:center;">O</th>
<th style="font-weight: bold;padding-top: 10px;text-align:center;">Total Direct Cost</th>
</thead><tbody>';
foreach ($opptPdctMap as $key => $optpdctArray) {
$tableCreation .= '<th style="padding: 3px;font-weight: bold;background-color:gray;color:white;" colspan="13">' . $key . '</th>';
foreach ($optpdctArray as $optKey => $optpdt) {
$totalDirectCost += $optpdt->Total_Direct_Cost->value;
$suggestedPrice += $optpdt->Final_Cost->value;
$totalMH += $optpdt->Total_MHR;
$tableCreation .= '<tr>
<td style="width: 8%; text-align: left; padding: 3px;">' . $optpdt->costbook->productcode . '</td>
<td style="width: 15%; text-align: left; padding: 3px;">' . $optpdt->name . '</td>
<td style="width: 4%; text-align: center; padding: 3px;">' . $optpdt->costbook->unitofmeasure . '</td>
<td style="width: 5%; text-align: center; padding: 3px">' . $optpdt->Quantity . '</td>
<td style="width: 5%; text-align: center; padding: 3px">' . $optpdt->Frequency . '</td>
<td style="width: 6%; text-align: center; padding: 3px">' . $optpdt->Total_MHR . '</td>
<td style="width: 6%;padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Labor_Cost . '</td>
<td style="width: 6%; padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Burden_Cost . '</td>
<td style="width: 6%;padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Materials_Cost . '</td>
<td style="width: 6%;padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Equipment_Cost . '</td>
<td style="width: 6%; padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Sub_Cost . '</td>
<td style="width: 6%; padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Other_Cost . '</td>
<td style="width: 16%; padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Total_Direct_Cost->value . '</td>
</tr>';
}
}
$tableCreation .= '</tbody></table>';
$tableCreation .= '<table style="margin-left: 20%; margin-top:2%;" border="0"
cellpadding="2" width="60%" text-align="right">
<tr>
<td rowspan="2" style="text-align:center; font-weight: bold;color:black;">Direct Cost</td>
<td style="text-align:right; font-weight: bold;color:black;">Total</td>
<td style="text-align:right;"></td>
<td style="text-align:right; font-weight: bold;color:black;">Suggested</td>
<td style="text-align:right; font-weight: bold;color:black;">Final</td>
</tr>
<tr>
<td style="text-align:right; color:black;">' . OpportunityProductUtils::getCurrencyType() . number_format($totalDirectCost, 2) . '</td>
<td style="text-align:right; font-weight: bold;color:black;">Price</td>
<td style="text-align:right; color:green;">' . OpportunityProductUtils::getCurrencyType() . number_format($suggestedPrice, 2) . '</td>
<td style="text-align:right; color:green;">' . OpportunityProductUtils::getCurrencyType() . number_format($opportunity->amount->value, 2) . '</td>
</tr>
<tr>
<td style="text-align:center; font-weight: bold;color:black;">MH</td>
<td style="text-align:right; color:black;">' . $totalMH . '</td>
<td style="text-align:right; font-weight: bold;color:black;">Rev/MH</td>
<td style="text-align:right; color:black;">' . OpportunityProductUtils::getCurrencyType() . number_format($suggestedPrice / $totalMH, 2) . '</td>
<td style="text-align:right;">' . OpportunityProductUtils::getCurrencyType() . number_format($opportunity->amount->value / $totalMH, 2) . '</td>
</tr>
<tr>
<td colspan="2" style="text-align:right;"></td>
<td style="text-align:right; font-weight: bold;color:black;">Aggregate GPM%</td>
<td style="text-align:right; color:black;">' . number_format(($suggestedPrice - $totalDirectCost) / $suggestedPrice * 100, 2) . ' </td>
<td style="text-align:right; color:black;">' . number_format(($opportunity->amount->value - $totalDirectCost) / $opportunity->amount->value * 100, 2) . '</td>
</tr>
</table>';
$tableCreation .= '</div><br/><br/><div style="background-color:#E0D1D1; color:black;padding:0.5%; margin-bottom:1%; font-weight:bold; font-size: 13px;">Charts</div>';
-($tableCreation .= OpportunityProductUtils::estimatorSummaryPiechartView($opportunityId));
-($tableCreation .= '<hr>');
$tableCreation .= '</div>';
$content .= $tableCreation;
}
$content .= '</tbody></table>
//.........这里部分代码省略.........
示例11: testUpdateAttributeValueAction
/**
* @depends testSuperUserKanbanBoardListAction
*/
public function testUpdateAttributeValueAction()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$this->assertEquals('Negotiating', self::$opportunity->stage->value);
//actionUpdateAttributeValue($id, $attribute, $value)
$this->setGetArray(array('id' => self::$opportunity->id, 'attribute' => 'stage', 'value' => 'Verbal'));
$this->runControllerWithNoExceptionsAndGetContent('opportunities/default/updateAttributeValue', true);
$id = self::$opportunity->id;
self::$opportunity->forget();
self::$opportunity = Opportunity::getById($id);
$this->assertEquals('Verbal', self::$opportunity->stage->value);
}
开发者ID:RamaKavanan,项目名称:BaseVersion,代码行数:15,代码来源:OpportunitiesSuperUserKanbanBoardWalkthroughTest.php
示例12: getsessionvalues
public function getsessionvalues($relationid)
{
$sql = "select * from opportunity where id=" . $relationid;
$rec = Yii::app()->db->createCommand($sql)->queryRow();
$rec_t['value'] = $rec_c['value'] = $rec_v['value'] = $rec_a['value'] = $rec_i['value'] = $rec_p['value'] = $bulkval = '';
if (isset($rec['totalbulkpricstm_currencyvalue_id']) && !empty($rec['totalbulkpricstm_currencyvalue_id'])) {
//get totalbuilprice
$sql_t = "select * from currencyvalue where id=" . $rec['totalbulkpricstm_currencyvalue_id'];
$rec_t = Yii::app()->db->createCommand($sql_t)->queryRow();
}
if (isset($rec['constructcoscstm_currencyvalue_id']) && !empty($rec['constructcoscstm_currencyvalue_id'])) {
$sql_c = "select * from currencyvalue where id=" . $rec['constructcoscstm_currencyvalue_id'];
$rec_c = Yii::app()->db->createCommand($sql_c)->queryRow();
}
if (isset($rec['vidpricingcscstm_currencyvalue_id']) && !empty($rec['vidpricingcscstm_currencyvalue_id'])) {
$sql_v = "select * from currencyvalue where id=" . $rec['vidpricingcscstm_currencyvalue_id'];
$rec_v = Yii::app()->db->createCommand($sql_v)->queryRow();
}
if (isset($rec['alarmbulkcstcstm_currencyvalue_id']) && !empty($rec['alarmbulkcstcstm_currencyvalue_id'])) {
$sql_a = "select * from currencyvalue where id=" . $rec['alarmbulkcstcstm_currencyvalue_id'];
$rec_a = Yii::app()->db->createCommand($sql_a)->queryRow();
}
if (isset($rec['internetbulkcstm_currencyvalue_id']) && !empty($rec['internetbulkcstm_currencyvalue_id'])) {
$sql_i = "select * from currencyvalue where id=" . $rec['internetbulkcstm_currencyvalue_id'];
$rec_i = Yii::app()->db->createCommand($sql_i)->queryRow();
}
if (isset($rec['phonebulkcstcstm_currencyvalue_id']) && !empty($rec['phonebulkcstcstm_currencyvalue_id'])) {
$sql_p = "select * from currencyvalue where id=" . $rec['phonebulkcstcstm_currencyvalue_id'];
$rec_p = Yii::app()->db->createCommand($sql_p)->queryRow();
}
if (isset($rec['bulkservprcscstm_multiplevaluescustomfield_id']) && !empty($rec['bulkservprcscstm_multiplevaluescustomfield_id'])) {
$sql_va = "select * from customfieldvalue where multiplevaluescustomfield_id=" . $rec['bulkservprcscstm_multiplevaluescustomfield_id'];
$rec_va = Yii::app()->db->createCommand($sql_va)->queryAll();
foreach ($rec_va as $key => $value) {
$bulkval .= $value['value'] . ",";
}
$bulkval = rtrim($bulkval, ",");
}
$getopportunity = Opportunity::getById(intval($relationid));
$getaccount = Account::getById(intval($getopportunity->account->id));
$_SESSION['unitsCstmCstm'] = !empty($getaccount->unitsCstmCstm) ? $getaccount->unitsCstmCstm : $_SESSION['unitsCstmCstm'] * 1;
$_SESSION['totalbulkpricstm'] = !empty($rec_t['value']) ? $rec_t['value'] : 1;
$_SESSION['totalcostprccstm'] = !empty($rec_c['value']) ? $_SESSION['unitsCstmCstm'] * $rec_c['value'] : 1;
$_SESSION['videopricstm'] = !empty($rec_v['value']) ? $rec_v['value'] : 0;
$_SESSION['alarampricstm'] = !empty($rec_a['value']) ? $rec_a['value'] : 0;
$_SESSION['phonepricstm'] = !empty($rec_p['value']) ? $rec_p['value'] : 0;
$_SESSION['internetpricstm'] = !empty($rec_i['value']) ? $rec_i['value'] : 0;
$_SESSION['bulkval'] = $bulkval;
if ($rec['closedate'] != '') {
$opportunity_closedate = explode("-", $rec['closedate']);
if (!empty($opportunity_closedate)) {
$_SESSION['opportunity_closedate'] = $opportunity_closedate[1] . "/" . $opportunity_closedate[2] . "/" . $opportunity_closedate[0];
}
}
}