if ($c != 0) { echo '<h6 style="color:red;">User name "' . $user->loginid . '" entered at line no. "' . $linenum . '" of uploaded excelsheet is already exists.</h6>'; goto loop; } // check costcenters $fac = trim($user->zonecode); $costcenter = $DB->get_record('local_costcenter', array('shortname' => $fac)); if (empty($costcenter)) { echo '<h6 style="color:red;">Invalid zonecode name "' . $user->zonecode . '" entered at line no. "' . $linenum . '" of uploaded excelsheet.</h6>'; goto loop; } $scid = $costcenter->id; $ccenter = new costcenter(); $costcenters = $ccenter->get_assignedcostcenters(); if (is_siteadmin()) { $costcenters = $ccenter->get_costcenter_items(); } $c = 0; foreach ($costcenters as $scl) { if ($scid == $scl->id) { ++$c; break; } } if ($c == 0) { echo '<h6 style="color:red;">Sorry you are not assigned to this zonecode "' . $user->zonecode . '" entered at line no. "' . $linenum . '" of uploaded excelsheet.</h6>'; goto loop; } // check dob $year = date("m/d/Y"); $year1 = strtotime($year);
public function definition() { global $USER, $CFG, $PAGE; $costcenter = new costcenter(); $mform = $this->_form; $id = $this->_customdata['id']; $costcenters = $this->_customdata['tool']; $editoroptions = $this->_customdata['editoroptions']; //if ($id < 0) // $mform->addElement('header', 'settingsheader', get_string('createcostcenter', 'local_costcenter')); //else // $mform->addElement('header', 'settingsheader', get_string('editcostcenter', 'local_costcenter')); $tools = array(); //$department = new department(); $selecttype = array(); $selecttype['1'] = get_string('department', 'local_costcenter'); $selecttype['2'] = get_string('location', 'local_costcenter'); $mform->addElement('select', 'type', get_string('type', 'local_costcenter'), $selecttype); $mform->addHelpButton('type', 'type', 'local_costcenter'); $mform->setType('type', PARAM_RAW); $items = $costcenter->get_costcenter_items(true); $parents = $costcenter->get_costcenter_parent($items, $costcenters->id); if (count($parents) <= 1) { $mform->addElement('hidden', 'parentid', 0); $mform->setType('parentid', PARAM_RAW); } else { $mform->addElement('select', 'parentid', get_string('parent', 'local_costcenter'), $parents); $mform->setType('parentid', PARAM_RAW); } $mform->addHelpButton('parentid', 'parent', 'local_costcenter'); $mform->addElement('text', 'fullname', get_string('costcentername', 'local_costcenter'), $tools); $mform->setType('fullname', PARAM_TEXT); $mform->addRule('fullname', get_string('missingcostcentername', 'local_costcenter'), 'required', null, 'client'); $mform->addElement('text', 'shortname', get_string('shortname','local_costcenter'), 'maxlength="100" size="20"'); //$mform->addHelpButton('shortname', 'shortnamelp'); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_TEXT); $attributes = array('rows' => '8', 'cols' => '40'); //$mform->addElement('textarea', 'description', get_string('description', 'local_costcenter'), null, $editoroptions); //$mform->setType('description', PARAM_RAW); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $now = date("d-m-Y"); $now = strtotime($now); $mform->addElement('hidden', 'timecreated', $now); $mform->setType('timecreated', PARAM_RAW); $mform->addElement('hidden', 'usermodified', $USER->id); $mform->setType('usermodified', PARAM_RAW); //$themelist = $costcenter->cobalt_get_theme_list(); //$mform->addElement('select', 'theme', get_string('theme', 'local_costcenter'), $themelist); //$mform->setType('theme', PARAM_RAW); //$mform->addRule('theme', get_string('missingtheme', 'local_costcenter'), 'required', null, 'client'); $submit = ($id > 0) ? get_string('update_costcenter', 'local_costcenter') : get_string('create', 'local_costcenter'); $this->add_action_buttons('false', $submit); }