public function add_company_selector($required = true) { $mform =& $this->_form; if (company_user::is_company_user()) { $mform->addElement('hidden', 'companyid', company_user::companyid()); } else { $companies = company::get_companies_rs(); $companyoptions = array('' => get_string('selectacompany', 'block_iomad_company_admin')); foreach ($companies as $company) { if (company_user::can_see_company($company->shortname)) { $companyoptions[$company->id] = $company->name; } } $companies->close(); if (count($companyoptions) == 1) { $mform->addElement('html', get_string('nocompanies', 'block_iomad_company_admin')); return false; } else { $mform->addElement('select', 'companyid', get_string('company', 'block_iomad_company_admin'), $companyoptions); if ($required) { $mform->addRule('companyid', get_string('missingcompany', 'block_iomad_company_admin'), 'required', null, 'client'); } $defaultvalues['companyid'] = array($this->selectedcompany); $mform->setDefaults($defaultvalues); } } return true; }
echo $OUTPUT->header(); echo $OUTPUT->notification($returnurl, get_string('deletednot', '', $company->name)); die; } $transaction->rollback(); } } } $blockpage->display_header(); // Check we can actually do anything on this page. iomad::require_capability('block/iomad_company_admin:company_view', $context); // Get the number of companies. $objectcount = $DB->count_records('company'); echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl); flush(); if ($companies = company::get_companies_rs($page, $perpage)) { $stredit = get_string('edit'); $strdelete = get_string('delete'); $strusers = $blockpage->get_string('company_users'); $strnewuser = $blockpage->get_string('newuser'); $strmanagers = $blockpage->get_string('company_managers'); $strcourses = $blockpage->get_string('company_courses'); $strcreatecourse = $blockpage->get_string('newcourse'); $strcourseusers = $blockpage->get_string('courseusers'); $strusersdownload = $blockpage->get_string('users_download'); $table = new html_table(); $table->head = array("Name", "Short name", "City", "", "", "", "", "", "", "", "", ""); $table->align = array("left", "left", "left", "center", "center", "center", "center", "center", "center", "center", "center", "center"); $table->width = "95%"; foreach ($companies as $company) { if (company_user::can_see_company($company)) {