/** * 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); }
/** * 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; }
?> <!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>
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); }