本文整理匯總了PHP中Opportunity::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Opportunity::model方法的具體用法?PHP Opportunity::model怎麽用?PHP Opportunity::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Opportunity
的用法示例。
在下文中一共展示了Opportunity::model方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getNames
public static function getNames()
{
$arr = Opportunity::model()->findAll();
$names = array(0 => 'None');
foreach ($arr as $opportunity) {
$names[$opportunity->id] = $opportunity->name;
}
return $names;
}
示例2: getStageMemberDataProviderMixed
/**
* Get a data provider with contacts, opportunities, and accounts
*/
public function getStageMemberDataProviderMixed($workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, $modelType = '')
{
$dateRange = self::getDateRange();
$expectedCloseDateDateRange = self::getDateRange('expectedCloseDateStart', 'expectedCloseDateEnd', 'expectedCloseDateRange');
if (!is_numeric($workflowId) || !is_numeric($stage)) {
return new CActiveDataProvider();
}
$records = array();
$attrs = array();
// AuxLib::debugLogR ('$modelType = ');
// AuxLib::debugLogR ($modelType);
// AuxLib::debugLogR (gettype ( $modelType));
// AuxLib::debugLogR (strlen ($modelType));
// AuxLib::debugLogR ($modelType[0]);
// AuxLib::debugLogR ($modelType[1]);
if (!empty($modelType)) {
AuxLib::coerceToArray($modelType);
}
// AuxLib::debugLogR ('$modelType = ');
// AuxLib::debugLogR ($modelType);
// CActiveDataProviders are used for the purposes of reusing code.
if (empty($modelType) || in_array('contacts', $modelType)) {
$contactsDataProvider = $this->getStageMemberDataProvider('contacts', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
$records['contacts'] = $contactsDataProvider->data;
$attrs = array_merge($attrs, Contacts::model()->attributeNames());
}
if (empty($modelType) || in_array('opportunities', $modelType)) {
$opportunitiesDataProvider = $this->getStageMemberDataProvider('opportunities', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
$records['opportunities'] = $opportunitiesDataProvider->data;
$attrs = array_merge($attrs, Opportunity::model()->attributeNames());
}
if (empty($modelType) || in_array('accounts', $modelType)) {
$accountsDataProvider = $this->getStageMemberDataProvider('accounts', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
$records['accounts'] = $accountsDataProvider->data;
$attrs = array_merge($attrs, Accounts::model()->attributeNames());
}
// get union of attribute names
$attrUnion = array_unique($attrs);
$attrUnion[] = 'actionLastUpdated';
// used to sort records
$combinedRecords = Record::mergeMixedRecords($records, $attrUnion);
/*
Sort records by the in descending order by the last time their associated workflow action
was updated. This allows Workflow stage listviews to be updated without reloading the
entire page. Every time a user drags a record from one stage to the next, placing that
record at the top of the target stage's list maintains the correct record ordering.
*/
usort($combinedRecords, function ($a, $b) {
if ($a['actionLastUpdated'] > $b['actionLastUpdated']) {
return -1;
} else {
if ($a['actionLastUpdated'] < $b['actionLastUpdated']) {
return 1;
} else {
return 0;
}
}
});
$dataProvider = new CArrayDataProvider($combinedRecords, array('pagination' => array('pageSize' => 20)));
$dataProvider->pagination->route = '/workflow/workflow/view';
$dataProvider->pagination->params = $_GET;
unset($dataProvider->pagination->params['ajax']);
return $dataProvider;
}