本文整理汇总了PHP中company::initialise_departments方法的典型用法代码示例。如果您正苦于以下问题:PHP company::initialise_departments方法的具体用法?PHP company::initialise_departments怎么用?PHP company::initialise_departments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类company
的用法示例。
在下文中一共展示了company::initialise_departments方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
public function definition()
{
global $CFG;
$mform =& $this->_form;
$company = new company($this->selectedcompany);
if (!($parentnode = company::get_company_parentnode($company->id))) {
// Company has not been set up, possibly from before an upgrade.
company::initialise_departments($company->id);
}
if (!empty($this->departmentid)) {
$departmentslist = company::get_all_subdepartments($this->departmentid);
} else {
$departmentslist = company::get_all_departments($company->id);
}
if (!empty($this->departmentid)) {
$department = company::get_departmentbyid($this->departmentid);
} else {
$department = company::get_company_parentnode($this->selectedcompany);
}
$subdepartmentslist = company::get_subdepartments_list($department);
$subdepartments = company::get_subdepartments($department);
// Create the sub department checkboxes html.
$subdepartmenthtml = "";
if (!empty($subdepartmentslist)) {
$subdepartmenthtml = "<div class='locationlist_container checkboxcontainer'>";
$subdepartmenthtml .= "<p>" . get_string('subdepartments', 'block_iomad_company_admin') . "</p>";
foreach ($subdepartmentslist as $key => $value) {
$subdepartmenthtml .= '<input type = "checkbox" name = "departmentids[]" value="' . $key . '" /> ' . $value . '</br>';
}
$subdepartmenthtml .= '</div>';
$subdepartmenthtml .= '<p><br/><input type="checkbox" id="selectallcheckbox" />Select all / Deselect All</p>';
}
// Then show the fields about where this block appears.
$mform->addElement('header', 'header', get_string('companydepartment', 'block_iomad_company_admin') . $company->get_name());
$mform->addElement('select', 'deptid', get_string('department', 'block_iomad_company_admin'), $departmentslist);
$mform->addElement('html', $subdepartmenthtml);
$buttonarray = array();
$buttonarray[] = $mform->createElement('submit', 'create', get_string('createdepartment', 'block_iomad_company_admin'));
if (!empty($subdepartmentslist)) {
$buttonarray[] = $mform->createElement('submit', 'edit', get_string('editdepartments', 'block_iomad_company_admin'), array('class' => 'editdepart'));
$buttonarray[] = $mform->createElement('submit', 'delete', get_string('deletedepartment', 'block_iomad_company_admin'));
}
$mform->addGroup($buttonarray, '', array(' '), ' ', false);
}
示例2: object
// Set up a profiles field category for this company.
$catdata = new object();
$catdata->sortorder = $DB->count_records('user_info_category') + 1;
$catdata->name = $data->shortname;
//$data->profileid = $DB->insert_record('user_info_category', $catdata, false);
// Code added by GWL
$data->profileid = $DB->insert_record('user_info_category', $catdata, true);
// End of Code
$companyid = $DB->insert_record('company', $data);
// code by GWL
if (!initialise_comapny_departments_titles($companyid)) {
print_error('errorcompanydefaultdepttitle', 'block_iomad_company_admin');
}
// end of code
// Set up default department.
company::initialise_departments($companyid);
$data->id = $companyid;
// Set up course category for company.
$coursecat = new object();
$coursecat->name = $data->name;
$coursecat->sortorder = 999;
$coursecat->id = $DB->insert_record('course_categories', $coursecat);
$coursecat->context = context_coursecat::instance($coursecat->id);
$categorycontext = $coursecat->context;
$categorycontext->mark_dirty();
$DB->update_record('course_categories', $coursecat);
fix_course_sortorder();
$companydetails = $DB->get_record('company', array('id' => $companyid));
$companydetails->category = $coursecat->id;
$DB->update_record('company', $companydetails);
// code by GWL
示例3: definition
public function definition()
{
global $CFG, $OUTPUT;
$mform =& $this->_form;
$company = new company($this->selectedcompany);
if (!($parentnode = company::get_company_parentnode($company->id))) {
// Company has not been set up, possibly from before an upgrade.
company::initialise_departments($company->id);
}
$regionlistarr = array('' => get_string('choose'));
if ($this->departmentid != $parentnode->id) {
$regionlist = company::get_my_region($this->departmentid);
if ($regionlist) {
$regionlistarr[$regionlist->id] = $regionlist->name;
}
} else {
$regionlist = company::get_all_regions($company->id);
foreach ($regionlist as $region) {
$regionlistarr[$region->id] = $region->name;
}
}
/* if(!$regionlist){
print_error("invalidaccess","block_iomad_admin");
}
*/
$department = '';
$subdepartmenthtml = "<div class='locationlist_container checkboxcontainer'>";
// echo "Region id" . $this->regionid;
$departments = '';
if (!$regionlist || $this->regionid) {
$regionid = $this->regionid ? $this->regionid : $this->departmentid;
if ($this->regionid) {
$departments = company::get_all_locations($regionid);
} else {
$departments[] = company::get_departmentbyid($regionid);
}
$subdepartmenthtml .= "<p>" . get_string('locations', 'block_iomad_company_admin') . "</p>";
$locationcount = 0;
foreach ($departments as $department) {
if ($department && $department->level == 1) {
// check foe the location
// Create the sub department checkboxes html.
$locationcount++;
$subdepartmenthtml .= '<input type = "checkbox" name = "locationids[]" value="' . $department->id . '" /> ' . $department->name . '</br>';
//if ($this->departmentid == $parentnode->id) {
//}
}
}
if ($departments && $locationcount > 1) {
$subdepartmenthtml .= '<p><br/><input type="checkbox" id="selectallcheckbox" />Select all / Deselect All</p>';
}
/* } else if ($this->departmentid != $parentnode->id) {
echo $OUTPUT->header();
echo $OUTPUT->notification(get_string('noaccesslocation', 'block_iomad_company_admin'));
echo $OUTPUT->footer();
die;
} */
// echo $subdepartmenthtml;
}
$subdepartmenthtml .= '</div>';
// Then show the fields about where this block appears.
$mform->addElement('header', 'header', get_string('companylocation', 'block_iomad_company_admin'));
//GWL : Remove Company Name
//$mform->addElement('html',$subdepartmenthtml);
$mform->addElement('hidden', 'departmentid', $this->departmentid);
$mform->setType('departmentid', PARAM_INT);
$attr = array('class' => 'editdepart');
$attr1 = array();
if ($regionlist) {
$mform->addElement('select', 'deptid', get_string('region', 'block_iomad_company_admin'), $regionlistarr, array('class' => 'region_select'));
if ($this->regionid) {
$mform->setDefault('deptid', $this->regionid);
}
$mform->addRule('deptid', get_string('regionnotselect', 'block_iomad_company_admin'), 'required', null, 'client');
// $attr['disabled'] = 'disabled';
// $attr1['disabled'] = 'disabled';
} else {
if ($this->departmentid != $parentnode->id) {
//$attr1['disabled'] = 'disabled';
}
}
if (!$departments) {
$attr['disabled'] = 'disabled';
$attr1['disabled'] = 'disabled';
}
$mform->addElement('html', $subdepartmenthtml);
$buttonarray = array();
if ($this->departmentid == $parentnode->id || $regionlist) {
$buttonarray[] = $mform->createElement('submit', 'create', get_string('createlocation', 'block_iomad_company_admin'), array('class' => 'checkboxcontainer'));
}
//if (!empty($subdepartmentslist)) {
$buttonarray[] = $mform->createElement('submit', 'edit', get_string('editlocations', 'block_iomad_company_admin'), $attr);
$buttonarray[] = $mform->createElement('submit', 'delete', get_string('deletelocation', 'block_iomad_company_admin'), $attr1);
// }
$mform->addGroup($buttonarray, '', array(' '), ' ', false);
}
示例4: definition
public function definition()
{
global $CFG, $USER;
$mform =& $this->_form;
$company = new company($this->selectedcompany);
if (!($parentnode = company::get_company_parentnode($company->id))) {
// Company has not been set up, possibly from before an upgrade.
company::initialise_departments($company->id);
}
if (!empty($this->departmentid)) {
$departmentslist = company::get_all_subdepartments($this->departmentid);
} else {
$departmentslist = company::get_all_departments($company->id);
}
if (!empty($this->departmentid)) {
$department = company::get_departmentbyid($this->departmentid);
} else {
$department = company::get_company_parentnode($this->selectedcompany);
}
/* GWL : Get Company Parent Node */
$parentnode = company::get_company_parentnode($this->selectedcompany);
$context = context_system::instance();
if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', $context)) {
$userhierarchylevel = $parentnode->id;
} else {
$userlevel = company::get_userlevel($USER);
$userhierarchylevel = $userlevel->id;
}
$subdepartmentslist = company::get_subdepartments_list($department);
$subdepartments = company::get_subdepartments($department);
$regionlistarr = array('' => get_string('choose'));
$showregiondropdown = 1;
$showlocationdropdown = 1;
if ($parentnode->id == $userhierarchylevel) {
$regionlist = company::get_all_regions($company->id);
foreach ($regionlist as $region) {
$regionlistarr[$region->id] = $region->name;
}
} else {
$regionlist = company::get_my_region($userhierarchylevel);
if (!$regionlist) {
$showregiondropdown = 0;
} else {
$regionlistarr[$regionlist->id] = $regionlist->name;
}
}
// Create the sub department checkboxes html.
$subdepartmenthtml = "<div class='departments_container'></div>";
$locationlist = array('' => get_string('choose'));
if ($parentnode->id != $userhierarchylevel && empty($regionlist)) {
$mylocationlist = company::get_my_location($userhierarchylevel);
if ($mylocationlist) {
$locationlist[$mylocationlist->id] = $mylocationlist->name;
} else {
$showlocationdropdown = 0;
}
}
/* if (!empty($subdepartmentslist)) {
$subdepartmenthtml = "<p>" . get_string('subdepartments', 'block_iomad_company_admin') .
"</p>";
foreach ($subdepartmentslist as $key => $value) {
$subdepartmenthtml .= '<input type = "checkbox" name = "departmentids[]" value="' .
$key . '" /> ' . $value . '</br>';
}
} */
// Then show the fields about where this block appears.
$mform->addElement('header', 'header', get_string('companydepartment', 'block_iomad_company_admin') . $company->get_name());
if ($showregiondropdown) {
$mform->addElement('select', 'regionid', get_string('region', 'block_iomad_company_admin'), $regionlistarr, array('class' => 'companyregion'));
$mform->addRule('regionid', get_string('regionnotselect', 'block_iomad_company_admin'), 'required', null, 'client');
}
if ($showlocationdropdown) {
$mform->addElement('select', 'locationid', get_string('location', 'block_iomad_company_admin'), $locationlist, array('class' => 'companylocation'));
$mform->addRule('locationid', get_string('locationnotselect', 'block_iomad_company_admin'), 'required', null, 'client');
}
//$mform->addElement('html', $subdepartmenthtml);
$mform->addElement('select', 'deptid', get_string('department', 'block_iomad_company_admin'), $locationlist, array('class' => 'dept_container'));
$mform->addElement('html', $subdepartmenthtml);
$buttonarray = array();
$attr = array();
if (!$showlocationdropdown) {
$attr = array('disabled' => 'disabled');
}
$buttonarray[] = $mform->createElement('submit', 'create', get_string('createdepartment', 'block_iomad_company_admin'), $attr);
// if (!empty($subdepartmentslist)) {
$buttonarray[] = $mform->createElement('submit', 'edit', get_string('editdepartments', 'block_iomad_company_admin'), array('disabled' => 'disabled', 'class' => 'editdepart'));
$buttonarray[] = $mform->createElement('submit', 'delete', get_string('deletedepartment', 'block_iomad_company_admin'), array('disabled' => 'disabled'));
//}
$mform->addGroup($buttonarray, '', array(' '), ' ', false);
}
示例5: definition
public function definition()
{
global $CFG, $OUTPUT;
$mform =& $this->_form;
$company = new company($this->selectedcompany);
if (!($parentnode = company::get_company_parentnode($company->id))) {
// Company has not been set up, possibly from before an upgrade.
company::initialise_departments($company->id);
}
$notcompanymanager = 0;
if ($this->departmentid != $parentnode->id) {
$regionlist = company::get_my_region($this->departmentid);
$notcompanymanager = 1;
} else {
$regionlist = company::get_all_regions($company->id);
}
//print_object($regionlist);
//die;
$companieslist = company::get_companies_select();
// Then show the fields about where this block appears.
$mform->addElement('header', 'header', get_string('companyregion', 'block_iomad_company_admin'));
//GWL : Remove Company Name
//$mform->addElement('select', 'deptid', get_string('company', 'block_iomad_company_admin'), $companieslist);
// $mform->addElement('html', $subdepartmenthtml);
$regionlisthtml = '';
if (!empty($regionlist)) {
$regionlisthtml = "<p>" . get_string('regions', 'block_iomad_company_admin') . "</p>";
$regioncount = 0;
if (!$notcompanymanager) {
$regionlisthtml = "<div class='locationlist_container checkboxcontainer'>";
foreach ($regionlist as $region) {
$regioncount++;
$regionlisthtml .= '<input type = "checkbox" name = "regionids[]" value="' . $region->id . '" /> ' . $region->name . '</br>';
}
} else {
$regionlisthtml .= '<input type = "checkbox" name = "regionids[]" value="' . $regionlist->id . '" /> ' . $regionlist->name . '</br>';
}
$regionlisthtml .= '</div>';
if ($this->departmentid == $parentnode->id && $regioncount > 1) {
$regionlisthtml .= '<p><br/><input type="checkbox" id="selectallcheckbox" />Select all / Deselect All</p>';
}
} else {
if (!company::can_manage_department($parentnode->id)) {
echo $OUTPUT->header();
echo $OUTPUT->notification(get_string('notaccessregion', 'block_iomad_company_admin'));
echo $OUTPUT->footer();
die;
}
}
$mform->addElement('html', $regionlisthtml);
$buttonarray = array();
if ($this->departmentid == $parentnode->id) {
$buttonarray[] = $mform->createElement('submit', 'create', get_string('createregion', 'block_iomad_company_admin'));
}
if (!empty($regionlist)) {
$buttonarray[] = $mform->createElement('submit', 'edit', get_string('editregions', 'block_iomad_company_admin'), array('class' => 'editdepart'));
if ($this->departmentid == $parentnode->id) {
$buttonarray[] = $mform->createElement('submit', 'delete', get_string('deleteregion', 'block_iomad_company_admin'));
}
}
$mform->addGroup($buttonarray, '', array(' '), ' ', false);
}