本文整理汇总了PHP中Companies::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Companies::getAll方法的具体用法?PHP Companies::getAll怎么用?PHP Companies::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Companies
的用法示例。
在下文中一共展示了Companies::getAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select_company
/**
* Render select company box
*
* @param integer $selected ID of selected company
* @param array $attributes Additional attributes
* @return string
*/
function select_company($name, $selected = null, $attributes = null)
{
$companies = Companies::getAll();
$options = array(option_tag(lang('none'), 0));
if (is_array($companies)) {
foreach ($companies as $company) {
$option_attributes = $company->getId() == $selected ? array('selected' => 'selected') : null;
$company_name = $company->getName();
if ($company->isOwner()) {
$company_name .= ' (' . lang('owner company') . ')';
}
$options[] = option_tag($company_name, $company->getId(), $option_attributes);
}
// foreach
}
// if
return select_box($name, $options, $attributes);
}
示例2: getGroupedByCompany
/**
* Return contacts grouped by company
*
* @param void
* @return array
*/
static function getGroupedByCompany()
{
$companies = Companies::getAll();
if (!is_array($companies) || !count($companies)) {
return null;
}
// if
$result = array();
foreach ($companies as $company) {
$contacts = $company->getContacts();
if (is_array($contacts) && count($contacts)) {
$result[$company->getName()] = array('details' => $company, 'contacts' => $contacts);
// array
}
// if
}
// foreach
return count($result) ? $result : null;
}
示例3:
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Edit Descriptions</title>
</head>
<body>
<form name="updateDescriptionForm" id="updateDescriptionForm">
<center>
Edit company:
<select id="company">
<option value="">Select a company to edit</option>
<?php
$companies = Companies::getAll();
foreach ($companies as $company) {
print "<option value=" . $company['id'] . ">";
print $company['name'];
print "</option>";
}
?>
</select>
<br><br>
<table border="1">
<tr>
<td valign="top">
<label for="description" id="descriptionLabel">
test1
</label>
</td>
示例4: share
function share()
{
$id = array_var($_GET, 'object_id');
$manager = array_var($_GET, 'manager');
$obj = get_object_by_manager_and_id($id, $manager);
if (!$obj instanceof DataObject) {
flash_error(lang('object dnx'));
ajx_current("empty");
return;
}
// if
$contacts = Contacts::getAll();
$allEmails = array();
$emailAndComp = array();
foreach ($contacts as $contact) {
if (trim($contact->getEmail()) != "") {
$emailStr = str_replace(",", " ", $contact->getFirstname() . ' ' . $contact->getLastname() . ' <' . $contact->getEmail() . '>');
$allEmails[] = $emailStr;
if ($contact->getCompany()) {
$emailAndComp[$emailStr] = $contact->getCompany()->getId();
}
}
}
$companies = Companies::getAll();
$allCompanies = array();
foreach ($companies as $comp) {
$allCompanies[$comp->getId()] = $comp->getName();
}
$actuallySharing = array();
$users = SharedObjects::getUsersSharing($id, $manager);
foreach ($users as $u) {
$user = Users::findById($u->getUserId());
if ($user) {
$actuallySharing[] = array('name' => $user->getDisplayName(), 'email' => $user->getEmail(), 'company' => $user->getCompany()->getName());
}
}
tpl_assign('allEmails', $allEmails);
tpl_assign('allCompanies', $allCompanies);
tpl_assign('emailAndComp', $emailAndComp);
tpl_assign('actuallySharing', $actuallySharing);
tpl_assign('object', $obj);
}