本文整理汇总了PHP中Opportunity::get_linked_beans方法的典型用法代码示例。如果您正苦于以下问题:PHP Opportunity::get_linked_beans方法的具体用法?PHP Opportunity::get_linked_beans怎么用?PHP Opportunity::get_linked_beans使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opportunity
的用法示例。
在下文中一共展示了Opportunity::get_linked_beans方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSalesStatus
/**
* Set the Sales Status based on the associated RLI's sales_stage
*
* @param Opportunity $bean
* @param string $event
* @param array $args
*/
public static function setSalesStatus(Opportunity $bean, $event, $args)
{
if (static::useRevenueLineItems() && $bean->ACLFieldAccess('sales_status', 'write')) {
// we have a new bean so set the value to new and dump out
if (empty($bean->fetched_row)) {
$bean->sales_status = Opportunity::STATUS_NEW;
return;
}
// Load forecast config so we have the sales_stage data.
static::loadForecastSettings();
// we don't have a new row, so figure out what we need to set it to
$closed_won = static::$settings['sales_stage_won'];
$closed_lost = static::$settings['sales_stage_lost'];
$won_rlis = count($bean->get_linked_beans('revenuelineitems', 'RevenueLineItems', array(), 0, -1, 0, "sales_stage in ('" . join("', '", $closed_won) . "')"));
$lost_rlis = count($bean->get_linked_beans('revenuelineitems', 'RevenueLineItems', array(), 0, -1, 0, "sales_stage in ('" . join("', '", $closed_lost) . "')"));
$total_rlis = count($bean->get_linked_beans('revenuelineitems', 'RevenueLineItems'));
if ($total_rlis > $won_rlis + $lost_rlis || $total_rlis === 0) {
// still in progress
$bean->sales_status = Opportunity::STATUS_IN_PROGRESS;
} else {
// they are equal so if the total lost == total rlis then it's closed lost,
// otherwise it's always closed won
if ($lost_rlis == $total_rlis) {
$bean->sales_status = Opportunity::STATUS_CLOSED_LOST;
} else {
$bean->sales_status = Opportunity::STATUS_CLOSED_WON;
}
}
}
}
示例2: addRealty
function addRealty(&$bean)
{
$bean->load_relationship("realty_contracts");
$bean->realty_contracts->delete($bean->id);
$opp = new Opportunity();
$opp->retrieve($bean->opp_id);
$realty_list = $opp->get_linked_beans('realty_opportunities', 'Opportunities');
foreach ($realty_list as $realty) {
$bean->realty_contracts->add($realty->id);
}
}
示例3: saveOpportunityProducts
/**
* Commit All Related Products from an Opportunity
*
* @param Opportunity $opp
* @param $isCommit
*/
public function saveOpportunityProducts(Opportunity $opp, $isCommit = false)
{
// remove the relationship if it exists as it could cause errors with the cached beans in the BeanFactory
if (isset($opp->revenuelineitems)) {
unset($opp->revenuelineitems);
}
// now save all related products to the opportunity
// commit every product associated with the Opportunity
$revenuelineitems = $opp->get_linked_beans('revenuelineitems', 'RevenueLineItems');
/* @var $product Product */
foreach ($revenuelineitems as $revenuelineitem) {
/* @var $product_wkst ForecastWorksheet */
$product_wkst = BeanFactory::getBean('ForecastWorksheets');
$product_wkst->saveRelatedProduct($revenuelineitem, $isCommit);
unset($product_wkst);
// clear the cache
}
}