本文整理汇总了PHP中Contacts::getGroupedByCompany方法的典型用法代码示例。如果您正苦于以下问题:PHP Contacts::getGroupedByCompany方法的具体用法?PHP Contacts::getGroupedByCompany怎么用?PHP Contacts::getGroupedByCompany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contacts
的用法示例。
在下文中一共展示了Contacts::getGroupedByCompany方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select_contact
/**
* Render select contact box
*
* @param integer $selected ID of selected contact
* @param array $exclude_contacts Array of IDs of contacts that need to be excluded (already attached to project etc)
* @param array $attributes Additional attributes
* @return string
*/
function select_contact($name, $selected = null, $exclude_contacts = null, $attributes = null)
{
$grouped_contacts = Contacts::getGroupedByCompany();
$all_options = array(option_tag(lang('none'), 0));
if (is_array($grouped_contacts)) {
foreach ($grouped_contacts as $company_name => $contacts) {
if (is_array($contacts) && is_array($contacts['contacts']) && count($contacts['contacts'])) {
$options = array();
foreach ($contacts['contacts'] as $contact) {
if (is_array($exclude_contacts) && in_array($contact->getId(), $exclude_contacts)) {
continue;
}
$contact_name = $contact->getDisplayName();
if ($contact->isAdministrator()) {
$contact_name .= ' (' . lang('administrator') . ')';
}
$option_attributes = $contact->getId() == $selected ? array('selected' => 'selected') : null;
$options[] = option_tag($contact_name, $contact->getId(), $option_attributes);
}
// foreach
if (count($options)) {
$all_options[] = option_tag('', 0);
// separator
$all_options[] = option_group_tag($company_name, $options);
}
// if
}
// if
}
// foreach
}
// if
return select_box($name, $all_options, $attributes);
}
示例2: filter_assigned_to_select_box
/**
* Render assign to SELECT
* @param string $list_name Name of the select control
* @param Project $project Selected project, if NULL active project will be used
* @param integer $selected ID of selected user
* @param array $attributes Array of select box attributes, if needed
* @return null
*/
function filter_assigned_to_select_box($list_name, $project = null, $selected = null, $attributes = null) {
$grouped_users = Contacts::getGroupedByCompany(false);
$options = array(option_tag(lang('anyone'), '0:0'),option_tag(lang('unassigned'), '-1:-1', '-1:-1' == $selected ? array('selected' => 'selected') : null));
if(is_array($grouped_users) && count($grouped_users)) {
foreach($grouped_users as $company_id => $users) {
$company = Contacts::findById($company_id);
if(!($company instanceof Contact)) {
continue;
} // if
$options[] = option_tag('--', '0:0'); // separator
$option_attributes = $company->getId() . ':0' == $selected ? array('selected' => 'selected') : null;
$options[] = option_tag($company->getName(), $company_id . ':0', $option_attributes);
if(is_array($users)) {
foreach($users as $user) {
$option_attributes = $company_id . ':' . $user->getId() == $selected ? array('selected' => 'selected') : null;
$options[] = option_tag($user->getObjectName() . ' : ' . $company->getObjectName() , $company_id . ':' . $user->getId(), $option_attributes);
} // foreach
} // if
} // foreach
} // if
return select_box($list_name, $options, $attributes);
} // assign_to_select_box
示例3: members
/**
* Show owner company members
*
* @access public
* @param void
* @return null
*/
function members()
{
if (!can_manage_security(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
tpl_assign('isMemberList', true);
tpl_assign('company', owner_company());
tpl_assign('users_by_company', Contacts::getGroupedByCompany());
}
示例4: assign_users
function assign_users()
{
if (!can_manage_billing(logged_user())) {
flash_error(lang("no access permissions"));
ajx_current("empty");
return;
}
$users_data = array_var($_POST, 'users');
if (is_array($users_data)) {
try {
DB::beginWork();
foreach ($users_data as $user_id => $user_billing) {
$user = Contacts::findById($user_id);
if ($user_billing != $user->getDefaultBillingId()) {
$user->setDefaultBillingId($user_billing);
$user->save();
}
}
DB::commit();
flash_success(lang("success assign user billing categories"));
ajx_current("back");
} catch (Exception $e) {
DB::rollback();
flash_error($e->getMessage());
ajx_current("empty");
}
}
tpl_assign('users_by_company', Contacts::getGroupedByCompany(false));
tpl_assign('billing_categories', BillingCategories::findAll());
}