public function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $company = new company($this->selectedcompany);
     $department = company_department::get_departmentbyid($this->deptid);
     // Then show the fields about where this block appears.
     if ($this->action == 0) {
         $mform->addElement('header', 'header', get_string('createdepartment', 'block_iomad_company_admin'));
     } else {
         $mform->addElement('header', 'header', get_string('editdepartments', 'block_iomad_company_admin'));
     }
     $mform->addElement('hidden', 'departmentid', $this->deptid);
     $mform->setType('departmentid', PARAM_INT);
     $mform->addElement('hidden', 'companyid', $this->selectedcompany);
     $mform->setType('companyid', PARAM_INT);
     $mform->addElement('hidden', 'action', $this->action);
     $mform->setType('action', PARAM_INT);
     //$mform->addElement('select', 'deptid', get_string('department', 'block_iomad_company_admin'), $departmentslist);
     //$mform->disabledIf('deptid', 'action', 'eq', 1);
     $mform->addElement('text', 'fullname', get_string('fullnamedepartment', 'block_iomad_company_admin'), 'maxlength = "254" size = "50"');
     $mform->addHelpButton('fullname', 'fullnamedepartment', 'block_iomad_company_admin');
     $mform->addRule('fullname', get_string('missingfullnamedepartment', 'block_iomad_company_admin'), 'required', null, 'client');
     $mform->setType('fullname', PARAM_MULTILANG);
     $mform->addElement('text', 'shortname', get_string('shortnamedepartment', 'block_iomad_company_admin'), 'maxlength = "100" size = "20"');
     $mform->addHelpButton('shortname', 'shortnamedepartment', 'block_iomad_company_admin');
     $mform->addRule('shortname', get_string('missingshortnamedepartment', 'block_iomad_company_admin'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_MULTILANG);
     /* if ($this->deptid) {
        echo "ggh";
        $mform->addElement('hidden', 'chosenid', $this->deptid);
        } else {
        $mform->addElement('hidden', 'chosenid', 0);
        } */
     //$mform->setType('chosenid', PARAM_INT);
     $this->add_action_buttons();
 }