function delete_learningplan_record($table, $id, $url, $lp_id = '') { global $DB, $OUTPUT; // Delete Department. $costcenter = new costcenter; if ($table == 'learning_learningplan') { /* * */ //$courses = $DB->get_fieldset_select('learning_plan_training','t_id',array('lp_id'=>$id)); //$users = $DB->get_fieldsetselect('learning_user_learningplan','u_id',array('lp_id'=>$id)); //foreach($users as $user){ // //} $DB->delete_records('learning_plan_training ', array('lp_id' => $id)); $DB->delete_records('learning_user_learningplan ', array('lp_id' => $id)); $DB->delete_records('learning_learningplan', array('id' => $id)); } else if ($table == 'learning_training') { $DB->delete_records('learning_training', array('id' => $id)); $training = $DB->get_field('learning_plan_training','t_id',array('id'=>$id)); $DB->delete_records('enrol',array('enrol'=>'learning_plan','courseid'=>$training)); $DB->delete_records('learning_plan_training', array('t_id' => $id)); } else if ($table == 'learning_plan_training') { $training = $DB->get_field('learning_plan_training','t_id',array('id'=>$id)); $userids = $DB->get_field('learning_user_trainingplan','u_id',array('lpt_id'=>$id)); $studentroleid = $DB->get_field('role', 'id', array('shortname' => 'student'), MUST_EXIST); $lplanenrol = new enrol_learning_plan_plugin; foreach($userids as $userid){ $enrol = $DB->get_record('enrol', array('courseid' => $training, 'enrol' => 'learning_plan')); $lplanenrol->unenrol_user($enrol, $id, $studentroleid); } $DB->delete_records('enrol',array('enrol'=>'learning_plan','courseid'=>$training)); $DB->delete_records('learning_plan_training', array('id' => $id)); } else if ($table == 'learning_user_learningplan') { $DB->delete_records('learning_user_learningplan', array('u_id' => $id, 'lp_id' => $lp_id)); // Remove all training in learning_user_trainingplan $sql = "select id from {learning_plan_training} where lp_id =?"; $lpts = $DB->get_recordset_sql($sql, array('lp_id' => $lp_id), $limitfrom = 0, $limitnum = 0); $training = learningplan_training($lp_id); foreach ($training as $train) { $studentroleid = $DB->get_field('role', 'id', array('shortname' => 'student'), MUST_EXIST); $manualenrol = enrol_get_plugin('manual'); $enrol = $DB->get_record('enrol', array('courseid' => $train->t_id, 'enrol' => 'manual')); $manualenrol->unenrol_user($enrol, $id, $studentroleid); } foreach ($lpts as $lpt) { $DB->delete_records('learning_user_trainingplan', array('u_id' => $id, 'lpt_id' => $lpt->id)); } } $style = array('style' => 'notifysuccess'); $costcenter->set_confirmation(get_string('learningplandeletedsuccess', 'block_learning_plan'), $url, $style); }
$userid = optional_param('userid', 0, PARAM_INT); $positionsids = optional_param('id', 0, PARAM_INT); $unassign = optional_param('unassign', 0, PARAM_BOOL); $confirm = optional_param('confirm', 0, PARAM_BOOL); $assign = optional_param('assign',0,PARAM_BOOL); $unassign = optional_param('unassign',0,PARAM_BOOL); require_login(); $systemcontext = context_system::instance(); if (!has_capability('local/positions:view', $systemcontext)) { print_error('nopermission'); } $positions = new positions(); $costcenter = new costcenter; if ($id > 0 && $edit) { $form_header = get_string('editpositions', 'local_positions'); $collapse = false; if (!($positions_instance = $DB->get_record('local_positions', array('id' => $id)))) { print_error('invalidtoolid1122', 'local_positions'); } $positions_instance->description = array('text' => $positions_instance->description, 'format' => FORMAT_HTML); } else { $form_header = get_string('createpositions', 'local_positions'); $collapse = true; $positions_instance = new stdClass(); $positions_instance->id = -1; } if ($unassign) {
* List the tool provided in a course * * @package local * @subpackage costcenter * @copyright 2015 Naveen <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once(dirname(__FILE__) . '/../../config.php'); global $CFG, $USER, $PAGE; require_once($CFG->dirroot . '/local/costcenter/lib.php'); $systemcontext = context_system::instance(); require_login(); $costcenter = new costcenter(); if (!has_capability('local/costcenter:view', $systemcontext)) { print_error('nopermission'); } $PAGE->set_pagelayout('admin'); $PAGE->set_context($systemcontext); $PAGE->set_url('/local/costcenter/info.php'); $PAGE->set_title(get_string('pluginname', 'local_costcenter')); $PAGE->navbar->add(get_string('pluginname', 'local_costcenter'), new moodle_url('/local/costcenter/index.php')); $PAGE->navbar->add(get_string('info', 'local_costcenter')); echo $OUTPUT->header();
redirect($CFG->wwwroot); } $PAGE->set_context($context); $PAGE->set_url($pageurl); $PAGE->set_pagelayout('standard'); $PAGE->set_heading(get_string('learning_plan', 'block_learning_plan')); $PAGE->set_title(get_string('learning_plan', 'block_learning_plan')); $PAGE->navbar->ignore_active(); $PAGE->navbar->add(get_string("pluginname", 'block_learning_plan'), new moodle_url($pageurl)); $output = $PAGE->get_renderer('block_learning_plan'); echo $output->header(); echo "<h2 class='tmhead2'>".get_string('pluginname', 'block_learning_plan')."</h2>"; $costcenter = new costcenter; $form_header = get_string('learningpath', 'block_learning_plan'); $form = new learningplan_form(null,array('id'=>$id)); // Edit Record. if ($edit) { $get_learningplan = $DB->get_record('learning_learningplan', array('id' => $id), '*'); $form->set_data($get_learningplan); } if ( $form->is_cancelled()) { redirect("{$CFG->wwwroot}" . "/blocks/learning_plan/view.php?viewpage=" . $viewpage); } // Insert or Update data - Save button Click. if ($fromform = $form->get_data()) { $fromform->timemodified = time(); $fromform->timecreated = time();
break; } } 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; }
$PAGE->set_context($systemcontext); $PAGE->set_title(get_string('assignmanager_title', 'local_costcenter')); $PAGE->set_heading($SITE->fullname); $PAGE->navbar->add(get_string('pluginname', 'local_costcenter'), "/local/costcenter/index.php", get_string('viewusers', 'local_costcenter')); $PAGE->navbar->add(get_string('assignusers', 'local_costcenter')); $PAGE->set_url(new moodle_url('/local/costcenter/assignusers.php', array('id' => $costcenterids))); $PAGE->set_pagelayout('admin'); $PAGE->requires->jquery(); $PAGE->requires->js('/local/costcenter/js/costcenter.js'); $PAGE->requires->js('/local/costcenter/js/delete_confirm.js'); $output = $PAGE->get_renderer('local_costcenter'); $returnurl = new moodle_url('/local/costcenter/assignusers.php', array('id' => $costcenterids)); $costcenter = new costcenter(); /* ---function for unassigning the users from costcenter--- */ if ($unassign) { $returnurl = new moodle_url('/local/costcenter/assignusers.php'); $PAGE->url->param('unassign', 1); if ($confirm and confirm_sesskey()) { $costcenter->unassign_users_instance($id, $userid); //echo $OUTPUT->confirm($message, $yesurl, $returnurl); } //$strheading = get_string('unassingheading', 'local_costcenter'); //$PAGE->navbar->add(get_string('pluginname', 'local_costcenter'), "/local/costcenter/index.php", get_string('viewcostcenter', 'local_costcenter')); //$PAGE->navbar->add($strheading); //$PAGE->set_title($strheading); //
public function assign_users($id) { global $CFG, $OUTPUT, $DB, $PAGE, $USER; $is_manager = $DB->record_exists_sql("select cp.* from {local_costcenter_permissions} as cp JOIN {role_assignments} as ra ON ra.userid=cp.userid and cp.userid=$USER->id JOIN {role} as r ON r.id=ra.roleid where r.archetype='manager'"); $urlparams = array('id' => $id); $costcenterid = $DB->get_field('learning_learningplan','costcenter',array('id'=>$id)); $lp_users = $DB->get_fieldset_sql("select u_id from {learning_user_learningplan} where lp_id=$id"); $lp_users = implode(',', $lp_users); if (is_siteadmin()) { $managers = $DB->get_records_sql_menu("SELECT u.id,u.username FROM {user} as u RIGHT JOIN {local_costcenter_permissions} as cp ON cp.userid=u.id group by u.id"); $sql = 'SELECT distinct(u.id), CONCAT(u.firstname," ", u.lastname) FROM {user} as u JOIN {local_userdata} as ud ON u.id=ud.userid and ud.costcenterid='.$costcenterid.''; } else if ($is_manager) { $costcenter = new costcenter(); $costcenterlist = $costcenter->get_assignedcostcenters(); $costcenterlist = $costcenter->get_costcenter_parent($costcenterlist, $selected = array(), $inctop = false, $all = false); $costcenteridin = implode(',', array_keys($costcenterlist)); //$sql = 'SELECT distinct(u.id), CONCAT(u.firstname," ", u.lastname) FROM {user} as u JOIN {local_userdata} as ud ON u.id=ud.userid where ud.costcenterid in(' . $costcenteridin . ')'; // code commented by sreenivas $sql = 'SELECT distinct(u.id), CONCAT(u.firstname," ", u.lastname) FROM {user} as u JOIN {local_userdata} as ud ON u.id=ud.userid where ud.costcenterid ='.$costcenterid.''; // code added by sreenivas } if (!empty($lp_users)) $sql .= ' AND u.id not in(' . $lp_users . ')'; $users = $DB->get_records_sql_menu($sql, array($params = null), $limitfrom = 0, $limitnum = 0); $output = ''; if (!$users) { $output .= $OUTPUT->heading(get_string("nousersyet", 'block_learning_plan'), 5); } else { if (is_siteadmin()) { $users = $users ; } $output .= '<form autocomplete="off" id="assign_user' . $id . '" action="view.php" method="post" accept-charset="utf-8" class="mform">'; $output .= '<input type="hidden" name="sesskey" value="' . sesskey() . '" />'; $output .= '<input type="hidden" name="viewpage" value="3" />'; $count = 0; $abletomoveusers = false; $baseurl = new moodle_url('/blocks/learning_plan/view.php', $urlparams + array('sesskey' => sesskey())); $output .= '<fieldset class="hidden"><div><div id="fitem_id_t_id[]" class="fitem fitem_fselect "><div class="fitemtitle"><label for="id_u_id[]">Select users</label></div><div class="felement ftext"><select name="u_id[]" id="assign_selects" size="10" multiple onchange="activate_submit(\'assign_user' . $id . '\',\'assign-user-select' . $id . '\')" class="assign-user-select' . $id . '">'; foreach ($users as $key => $value) { $output .= '<option value=' . $key . '>' . $value . '</option>'; } $output .= "</select></div></div></div></fieldset>"; $output .= '<input type="hidden" name="l_id" value=' . $id . ' />'; $output .= '<fieldset class="hidden"><div><div id="fitem_id_submitbutton" class="fitem fitem_actionbuttons fitem_fsubmit"><div class="felement fsubmit"><input type="submit" id="movetoid' . $id . '" class="form-submit" disabled value="Assign users" /></div></div>'; $output .= '</div></fieldset></form>'; } $output .= html_writer::link(new moodle_url('/blocks/learning_plan/enrolluser.php', array('lpid' => $id)), 'Enroll multiple users'); return $output; }
function definition() { global $USER, $CFG, $DB, $PAGE; global $myuser; $costcenter = new costcenter(); $mform = $this->_form; $positions=new positions(); $id = $this->_customdata['id']; $editoroptions = $this->_customdata['editoroptions']; $filemanageroptions = $this->_customdata['filemanageroptions']; $admin = $this->_customdata['admin']; $mform->addElement('header', 'moodle', get_string('generaldetails', 'local_users')); if (!$admin) { $mform->addElement('date_selector', 'dateofapplication', get_string('joiningdate', 'local_users')); } if (is_siteadmin($USER->id)) { $costcenters = $DB->get_records('local_costcenter', array('visible' => 1)); $Position =$DB->get_records('local_positions',array('visible'=>1)); } else { $costcenters = $costcenter->get_assignedcostcenters(); } $parents = $costcenter->get_costcenter_parent($costcenters, '', $top = true, $all = false); $position =$positions->get_positions_parent($Position,'', $top=true, $all = false); $count = count($costcenters); $mform->addElement('hidden', 'count', $count); $mform->setType('count', PARAM_INT); if ($id > 0) { $mform->addElement('static', 'costcenter_name', get_string('costcenterid', 'local_costcenter')); //$mform->addElement('static', 'role_name', get_string('role', 'local_users')); } else { if ($count == 1) { //registrar is assigned to only one costcenter, display as static foreach ($costcenters as $scl) { $key = $scl->id; $value = $scl->fullname; } $mform->addElement('static', 'costcenters', get_string('costcenterid', 'local_costcenter'), $value); $mform->addElement('hidden', 'costcenterid', $key); $mform->setType('costcenterid', PARAM_INT); } else { $costcenters = $mform->addElement('select', 'costcenterid', get_string('select', 'local_costcenter'), $parents); $mform->addHelpButton('costcenterid', 'assigncostcenter', 'local_costcenter'); $mform->addRule('costcenterid', get_string('required'), 'required', null, 'client'); } // $systemroles = $myuser->systemroles_custom(); // $mform->addElement('select', 'roleid', get_string('selectrole', 'local_users'), $systemroles); // $mform->addHelpButton('roleid', 'assignrole', 'local_users'); // $mform->addRule('roleid', get_string('required'), 'required', null, 'client'); } $mform->addElement('text', 'username', get_string('username', 'local_users')); $mform->addRule('username', get_string('required'), 'required', null, 'client'); $mform->setType('username', PARAM_RAW); if (!empty($CFG->passwordpolicy)) { $mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy()); } $mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"'); $mform->addHelpButton('newpassword', 'newpassword'); $mform->setType('newpassword', PARAM_RAW); if ($id < 0) $mform->addRule('newpassword', get_string('required'), 'required', null, 'client'); $mform->addElement('header', 'moodle', get_string('personaldetails', 'local_users')); $mform->addElement('text', 'firstname', get_string('firstname', 'local_users')); $mform->addRule('firstname', get_string('required'), 'required', null, 'client'); $mform->setType('firstname', PARAM_RAW); $mform->addElement('text', 'middlename', get_string('middlename', 'local_users')); $mform->setType('middlename', PARAM_RAW); $mform->addElement('text', 'lastname', get_string('lastname', 'local_users')); $mform->addRule('lastname', get_string('required'), 'required', null, 'client'); $mform->setType('lastname', PARAM_RAW); //$costcenters = $mform->addElement('select', 'position', get_string('select', 'local_positions'), $position); //$mform->addHelpButton('position', 'assignpositions', 'local_positions'); //$mform->addRule('position', get_string('required'), 'required', null, 'client'); $radioarray = array(); $radioarray[] = & $mform->createElement('radio', 'gender', '', get_string('male', 'local_users'), 'M'); $radioarray[] = & $mform->createElement('radio', 'gender', '', get_string('female', 'local_users'), 'F'); $mform->addGroup($radioarray, 'gender', 'Gender', array(' '), false); $mform->setDefault('gender', 'Male'); //if (!$admin) { // $mform->addElement('date_selector', 'dob', get_string('dob', 'local_users')); // $mform->addHelpButton('dob', 'dateofbirth', 'local_users'); //} /************************************code by sreekanth**********************************************/ $mform->addElement('header', 'otherdetails', get_string('otherdetails', 'local_users')); $mform->addElement('text', 'designation', get_string('designation', 'local_users')); $mform->setType('designation', PARAM_RAW); $mform->addElement('text', 'level', get_string('level', 'local_users')); $mform->setType('level', PARAM_RAW); $mform->addElement('date_selector', 'doj', get_string('dateofjoin', 'local_users')); $mform->addElement('date_selector', 'dob', get_string('dateofbirth', 'local_users')); $mform->addElement('text', 'eligibility', get_string('eligibility', 'local_users')); $mform->setType('eligibility', PARAM_RAW); $mform->addElement('text', 'vertical', get_string('vertical', 'local_users')); $mform->setType('vertical', PARAM_RAW); $mform->addElement('text', 'state', get_string('state', 'local_users')); $mform->setType('state', PARAM_RAW); $mform->addElement('text', 'branch', get_string('branch', 'local_users')); $mform->setType('branch', PARAM_RAW); $mform->addElement('text', 'jobfunction', get_string('jobfunction', 'local_users')); $mform->setType('jobfunction', PARAM_RAW); $mform->addElement('text', 'grade', get_string('grade', 'local_users')); $mform->setType('grade', PARAM_RAW); $mform->addElement('text', 'experience', get_string('experience', 'local_users')); $mform->setType('experience', PARAM_INT); $mform->addElement('text', 'qualification', 'Qualification'); $mform->setType('qualification', PARAM_RAW); $mform->addElement('text', 'category', get_string('category', 'local_users')); $mform->setType('category', PARAM_RAW); $mform->addElement('text', 'department', get_string('department', 'local_users')); $mform->setType('department', PARAM_RAW); /*end of code by sreekanth*/ $mform->addElement('header', 'moodle', get_string('contactdetails', 'local_users')); $mform->addElement('text', 'phone1', get_string('phone', 'local_users')); $mform->addRule('phone1', get_string('required'), 'required', null, 'client'); $mform->addRule('phone1', get_string('numeric','local_users'), 'numeric', null, 'client'); $mform->addRule('phone1', get_string('phoneminimum', 'local_users'), 'minlength', 10, 'client'); $mform->addRule('phone1', get_string('phonemaximum', 'local_users'), 'maxlength', 15, 'client'); $mform->setType('phone1', PARAM_RAW); $mform->addElement('text', 'email', get_string('email', 'local_users')); $mform->addRule('email', get_string('required'), 'required', null, 'client'); $mform->addRule('email', get_string('emailerror', 'local_users'), 'email', null, 'client'); $mform->setType('email', PARAM_RAW); $mform->addElement('text', 'city', get_string('city')); $mform->addRule('city', get_string('required'), 'required', null, 'client'); $mform->setType('city', PARAM_RAW); $country = get_string_manager()->get_list_of_countries(); $default_country[''] = get_string('selectacountry'); $country = array_merge($default_country, $country); $mform->addElement('select', 'country', get_string('country'), $country); $mform->addRule('country', get_string('country_error','local_users'), 'required', null, 'client'); $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations()); $mform->setDefault('lang', $CFG->lang); $mform->addElement('textarea', 'address', get_string('address', 'local_users')); $mform->addElement('editor', 'description_editor', get_string('userdescription'), null, $editoroptions); $mform->setType('description_editor', PARAM_CLEANHTML); $mform->addHelpButton('description_editor', 'userdescription'); $mform->addElement('header', 'moodle', get_string('userpicture', 'local_users')); $mform->addElement('static', 'currentpicture', get_string('currentpicture')); $mform->addElement('checkbox', 'deletepicture', get_string('delete')); $mform->setDefault('deletepicture', 0); $mform->addElement('filemanager', 'imagefile', get_string('newpicture'), '', $filemanageroptions); $mform->addHelpButton('imagefile', 'newpicture'); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $submitlable = ($id > 0) ? get_string('updateuser', 'local_users') : get_string('createuser', 'local_users'); $this->add_action_buttons(true, 'Submit'); }
$page = optional_param('page', 0, PARAM_INT); $moveto = optional_param('moveto', 0, PARAM_INT); $sesskey = optional_param('sesskey', '', PARAM_RAW); $userid = optional_param('userid', 0, PARAM_INT); $costcenterids = optional_param('id', 0, PARAM_INT); $unassign = optional_param('unassign', 0, PARAM_BOOL); $confirm = optional_param('confirm', 0, PARAM_BOOL); $employe_assign = optional_param('eassign',0,PARAM_BOOL); require_login(); $systemcontext = context_system::instance(); if (!has_capability('local/costcenter:view', $systemcontext)) { print_error('nopermission'); } $costcenter = new costcenter(); if($employe_assign ){ if($data = data_submitted()){ foreach($data->u_id as $userid){ $userdata = new stdClass(); $userdata->userid = $userid; $userdata->costcenterid = $id; $userdata->supervisorid = 0; $userdata->reportingmanagerid = 0; $userdata->usermodified = $USER->id; $userdata->timecreated = time(); $userdata->timemodified = time(); $DB->insert_record('local_userdata',$userdata); } redirect($PAGE->url); }
* @package local * @subpackage user * @copyright 2015 onwards Sreenivas <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require('../../config.php'); require_once($CFG->libdir . '/adminlib.php'); require_once($CFG->libdir . '/csvlib.class.php'); require_once('agent_upload_lib.php'); require_once('agent_upload_form.php'); require_once($CFG->dirroot.'/local/costcenter/lib.php'); require_once('lib.php'); //require_once($CFG->dirroot . '/local/lib.php'); $iid = optional_param('iid', '', PARAM_INT); $previewrows = optional_param('previewrows', 10, PARAM_INT); $costcenter = new costcenter(); @set_time_limit(60 * 60); // 1 hour should be enough raise_memory_limit(MEMORY_HUGE); require_login(); $errorstr = get_string('error'); $stryes = get_string('yes'); $strno = get_string('no'); $stryesnooptions = array(0 => $strno, 1 => $stryes); global $USER, $DB; $systemcontext = context_system::instance(); $PAGE->set_context($systemcontext); $PAGE->set_pagelayout('admin');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once(dirname(__FILE__) . '/../../config.php'); global $CFG,$DB,$PAGE; require_once($CFG->dirroot . '/local/costcenter/lib.php'); require_once($CFG->dirroot.'/local/evaluations/create_form.php'); $id = optional_param('id',-1,PARAM_INT); $classid = required_param('clid',PARAM_INT); $delete = optional_param('delete', 0, PARAM_BOOL); $confirm = optional_param('confirm', 0, PARAM_BOOL); $visible = optional_param('visible', -1, PARAM_INT); $PAGE->set_url('/local/evaluations/create_evaluation.php',array('clid'=>$classid)); $PAGE->set_pagelayout('admin'); $systemcontext = context_system::instance(); require_login(); $costcenter = new costcenter(); $PAGE->set_context($systemcontext); require_capability('local/evaluations:addinstance', context_system::instance()); //Header and the navigation bar $PAGE->set_heading($SITE->fullname); $PAGE->set_title(get_string('pluginname','local_evaluations')); if ($id > 0) { if (! ($evaluation = $DB->get_record('local_evaluation', array('id'=>$id)))) { print_error('invalidtoolid', 'local_academiccalendar'); } } else { $evaluation = new stdClass(); $evaluation->id = -1;
/** * deletes a template * * @author Andreas Grabs * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package evaluation */ require_once("../../config.php"); require_once("lib.php"); require_once('delete_template_form.php'); require_once($CFG->libdir.'/tablelib.php'); require_once($CFG->dirroot . '/local/costcenter/lib.php'); $current_tab = 'templates'; $costcenter = new costcenter(); $id = required_param('id', PARAM_INT); $classid = required_param('clid',PARAM_INT); $canceldelete = optional_param('canceldelete', false, PARAM_INT); $shoulddelete = optional_param('shoulddelete', false, PARAM_INT); $deletetempl = optional_param('deletetempl', false, PARAM_INT); $PAGE->set_pagelayout('admin'); $context = context_system::instance(); require_login(); $PAGE->set_context($context); $url = new moodle_url('/local/evaluations/delete_template.php', array('id'=>$id,'clid'=>$classid)); if ($canceldelete !== false) { $url->param('canceldelete', $canceldelete); } if ($shoulddelete !== false) {
/** * Candidate users * @param string $search * @return array */ public function find_users($search) { global $DB; if(!is_siteadmin()){ $costcenter = new costcenter(); $costcenterlist = $costcenter->get_assignedcostcenters(); $costcenterlist = $costcenter->get_costcenter_parent($costcenterlist, $selected = array(), $inctop = false, $all = false); $costcenteridin = implode(',', array_keys($costcenterlist)); $userdata_sql = "select userid from {local_userdata} where costcenterid in($costcenteridin)"; //if(!empty($this->skillset)&&$this->skillset!=null) //$userdata_sql .=" AND skillset='$this->skillset'"; //if(!empty($this->position)&&$this->position!=null) //$userdata_sql .=" AND position='$this->position'"; $users_list = $DB->get_fieldset_sql($userdata_sql); $users_list = implode(',',$users_list); }elseif(is_siteadmin()){ $userdata_sql = "select userid from {local_userdata} where id>0"; //if(!empty($this->skillset)) //$userdata_sql .=" AND skillset='$this->skillset'"; //if(!empty($this->position)) //$userdata_sql .=" AND position='$this->position'"; // $userdata_sql; $users_list = $DB->get_fieldset_sql($userdata_sql); $users_list = implode(',',$users_list); } // By default wherecondition retrieves all users except the deleted, not confirmed and guest. list($wherecondition, $params) = $this->search_sql($search, 'u'); $params['enrolid'] = $this->enrolid; $fields = 'SELECT ' . $this->required_fields_sql('u'); $countfields = 'SELECT COUNT(1)'; $sql = " FROM {user} u JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid) WHERE $wherecondition"; if(!empty($users_list) && !is_siteadmin()) $sql .=" AND u.id in($users_list)"; list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext); $order = ' ORDER BY ' . $sort; if (!$this->is_validating()) { $potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params); if ($potentialmemberscount > $this->maxusersperpage) { return $this->too_many_results($search, $potentialmemberscount); } } if(empty($users_list) && !is_siteadmin()) $availableusers = array(); else $availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams)); if (empty($availableusers)) { return array(); } if ($search) { $groupname = get_string('enrolledusersmatching', 'enrol', $search); } else { $groupname = get_string('enrolledusers', 'enrol'); } return array($groupname => $availableusers); }
function get_costcenter() { global $DB,$CFG,$PAGE; require_once($CFG->dirroot . '/local/costcenter/lib.php'); $PAGE->requires->js('/local/batches/js/batches.js'); $costcenter = new costcenter(); //$designation_list = $DB->get_records_sql('select distinct(designation) as designation from {local_userdata} where designation!=""'); if (is_siteadmin() || is_odmanager()) { $costcenters = $DB->get_records('local_costcenter', array('visible' => 1)); } else { $costcenters = $costcenter->get_assignedcostcenters(); } echo " <select name='costcenter[]' id=\"assign_selects\" multiple onchange=\"activate_submit(\'assign_user' . $id . '\',\'assign-user-select' . $id . '\')\" class=\"assign-user-select' . $id . '\"> <option value='null'>--Select Department--</option> <option value='-1'>All</option>"; foreach($costcenters as $costcenter) { echo "<option value='$costcenter->id'>$costcenter->fullname</option>"; } echo "</select>" ; }
/** * @method treeview * @todo To add action buttons */ public function departments_view() { global $DB, $CFG, $OUTPUT, $USER,$PAGE; $systemcontext = context_system::instance(); $costcenter_instance = new costcenter; if (is_siteadmin()) { $sql = "SELECT distinct(s.id),s.* FROM {local_costcenter} s ORDER BY s.sortorder"; } else { $sql = "SELECT distinct(s.id),s.* FROM {local_costcenter} s where id in(select costcenterid from {local_costcenter_permissions} sp where sp.costcenterid=s.id AND sp.userid={$USER->id}) ORDER BY s.sortorder "; } $costcenters = $DB->get_records_sql($sql); if (!is_siteadmin() && empty($costcenters)) { print_error('notassignedcostcenter', 'local_costcenter'); } $data = array(); foreach ($costcenters as $costcenter) { $employes_count = $DB->count_records('local_userdata',array('costcenterid'=>$costcenter->id,'lastworkingdate'=>NULL)); $managers_count = $DB->count_records_sql('select COUNT(u.id) from {user} as u JOIN {local_costcenter_permissions} as cp on u.id=cp.userid where costcenterid='.$costcenter->id.''); $course_count = $DB->count_records('course',array('costcenter'=>$costcenter->id)); $tmanager_count = $DB->count_records_sql('select count(distinct tmap.teammanagerid) as tmanagercount from {local_teammanager_employee} as tmap JOIN {local_userdata} as ud ON ud.userid=tmap.teammanagerid JOIN {user} as u ON u.id=ud.userid where ud.costcenterid='.$costcenter->id.''); $line = array(); $linkcss = $costcenter->visible ? ' ' : 'class="dimmed" '; $showdepth = 1; $managers_list = $costcenter_instance->get_costcenter_managers($costcenter->id); if(empty($managers_list)) $managers_list = '<i>Not assigned</i>'; $buttons = array(); $sql = " SELECT distinct(s.id),s.* FROM {local_costcenter} s where s.id={$costcenter->id} AND id in(select costcenterid from {local_costcenter_permissions} where costcenterid={$costcenter->id} AND userid={$USER->id}) ORDER BY s.sortorder "; $checkpermissions = $DB->get_records_sql($sql); $delete_cap = array('local/costcenter:manage', 'local/costcenter:delete'); if (has_any_capability($delete_cap, $systemcontext)) { // code by sreenivas 27/10/2015 $check_users = $DB->get_records('local_userdata', array('costcenterid' => $costcenter->id)); $check_user_roles = $DB->get_records('local_costcenter_permissions', array('costcenterid' => $costcenter->id)); $check_plans = $DB->get_records('learning_learningplan', array('costcenter' => $costcenter->id)); $checkchilditems = $DB->get_records('local_costcenter', array('parentid' => $costcenter->id)); $check_course = $DB->get_records('course', array('costcenter' => $costcenter->id)); if ($checkchilditems) { $message = get_string('cannotdeletecostcenter', 'local_costcenter', array('scname' => $costcenter->fullname)); $buttons[] = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/risk_xss'), 'title' => $message, 'alt' => $message, 'class' => 'iconsmall')); } else if ($check_plans) { /* check if any plan under costcenter */ $buttons[] = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/risk_xss'), 'title' => get_string('cantplans', 'local_costcenter'), 'alt' => get_string('cantplans', 'local_costcenter'), 'class' => 'iconsmall')); } else if ($check_course){ /* check if any course under costcenter */ $buttons[] = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/risk_xss'), 'title' => get_string('cantcourse', 'local_costcenter'), 'alt' => get_string('cantcourse', 'local_costcenter'), 'class' => 'iconsmall')); } else if ($check_users){ /* check if any user under costcenter */ $buttons[] = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/risk_xss'), 'title' => get_string('cantusers', 'local_costcenter'), 'alt' => get_string('cantusers', 'local_costcenter'), 'class' => 'iconsmall')); } else { // all clear $buttons[] = html_writer::link(new moodle_url('/local/costcenter/costcenter.php', array('id' => $costcenter->id, 'view' => 0, 'delete' => 1, 'sesskey' => sesskey())), html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/aia/delete'),'onmouseover' => "this.src='".$OUTPUT->pix_url('t/aia/delete1')."'", 'onmouseout' => "this.src='".$OUTPUT->pix_url('t/aia/delete')."'", 'title' => get_string('delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall')), array('id' => 'deleteconfirm' . $costcenter->id . '')); $PAGE->requires->event_handler('#deleteconfirm'.$costcenter->id.'', 'click', 'M.util.tmahendra_show_confirm_dialog', array('message' => get_string('delconfirm', 'local_costcenter'), 'callbackargs' => array('id' => $costcenter->id))); } } $update_cap = array('local/costcenter:manage', 'local/costcenter:update'); if (has_any_capability($update_cap, $systemcontext)) { //$script = ' //function change(id){ //alert(id); //$("#show"+id"").css("display", "none"); // // ////alert("iam "+id); //// var sourceSwap = function () { //// var $this = $(this); //// var newSource = $this.data("alt-src"); //// $this.data("alt-src", $this.attr("src")); //// $this.attr("src", newSource); //// } //// var s = document.getElementById("enroluser"+id); //// s.style.fill = "FFF"; //// //// $(function () { //// $("#enroluser"+id).hover(sourceSwap, sourceSwap); //// }); //};'; //$script = ' //function change(id){ ////alert(id); //$("#show"+id+"").css("display", "none"); //$("#hide"+id+"").css("display", "inline"); ////$("#enroluser"+id").function() { ////$(this).attr("src", "http://d3l2031tfshpe7.cloudfront.net/Images/Product/DRS00420A/2.jpg"); ////} //} //'; //$script='function change(id){ // // $(#enroluser"+id+"").addClass("hidden"); // $("#social_buttons").fadeIn("fast"); // // setTimeout(function(){ // $("#social_buttons").hide(); // //$("#social").removeClass("hidden"); // }, 50002); // ); // // // var s = null; // $( "#social_buttons" ).mouseout(function() { // clearTimeout(s); // $(this).hide(); // //$("#social").removeClass("hidden"); // s = setTimeout("$("#social").removeClass("hidden");", 100); // }); //}'; //echo html_writer::script($script); $imgUrl = $OUTPUT->pix_url("t/aia/assignmanage"); $buttons[] = html_writer::link("javascript:void(0)", html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/aia/assignmanage'),'onmouseover' => "this.src='".$OUTPUT->pix_url('t/aia/assignmanage1')."'", 'onmouseout' => "this.src='".$OUTPUT->pix_url('t/aia/assignmanage')."'", 'alt' => get_string('assignusers', 'local_costcenter'), 'class' => 'iconsmall')), //html_writer::empty_tag('img', array('src' => $CFG->wwwroot.'/pix/t/enrolusers.svg'/*, 'onmouseover' => 'change('.$costcenter->id.')'*/, 'alt' => get_string('assignusers', 'local_costcenter'), 'class' => 'iconsmall', 'id'=>'show'.$costcenter->id)). //html_writer::empty_tag('img', array( 'src' => $CFG->wwwroot.'/pix/t/check.png'/*, 'onmouseover' => 'change('.$costcenter->id.')'*/, 'style' => 'display: none;', 'alt' => get_string('assignusers', 'local_costcenter'), 'class' => 'iconsmall', 'id'=>'hide'.$costcenter->id)), array('title' => get_string('assignusers', 'local_costcenter'),'id'=>'assignmanager'.$costcenter->id.'','onclick'=>'assign_manager('.$costcenter->id.')')); $buttons[] = html_writer::link("javascript:void(0)", html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/aia/assignstudent'),'onmouseover' => "this.src='".$OUTPUT->pix_url('t/aia/assignstudent1')."'", 'onmouseout' => "this.src='".$OUTPUT->pix_url('t/aia/assignstudent')."'", 'alt' => get_string('assignemployee', 'local_costcenter'), 'class' => 'iconsmall')), array('title' => get_string('assignemployee', 'local_costcenter'),'id'=>'assignemployee'.$costcenter->id.'','onclick'=>'assign_employee('.$costcenter->id.')')); $buttons[] = html_writer::link(new moodle_url('/local/costcenter/index.php', array('id' => $costcenter->id, 'sesskey' => sesskey())), html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/aia/edit'),'onmouseover' => "this.src='".$OUTPUT->pix_url('t/aia/edit1')."'", 'onmouseout' => "this.src='".$OUTPUT->pix_url('t/aia/edit')."'", 'title' => get_string('edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall'))); //$PAGE->requires->event_handler('enroltocourse'.$cohort->id.'', 'click', 'test', array('context'=>$cohort->contextid,'cohortid'=>$cohort->id )); } $visible_cap = array('local/costcenter:manage', 'local/costcenter:manager'); if (has_any_capability($visible_cap, $systemcontext)) { if ($costcenter->visible) { $buttons[] = html_writer::link(new moodle_url('/local/costcenter/costcenter.php', array('id' => $costcenter->id, 'hide' => 1, 'sesskey' => sesskey())), html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/aia/view'),'onmouseover' => "this.src='".$OUTPUT->pix_url('t/aia/view1')."'", 'onmouseout' => "this.src='".$OUTPUT->pix_url('t/aia/view')."'", 'title' => get_string('inactive'), 'alt' => get_string('hide')))); } else { $buttons[] = html_writer::link(new moodle_url('/local/costcenter/costcenter.php', array('id' => $costcenter->id, 'show' => 1, 'sesskey' => sesskey())), html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/aia/hide'),'onmouseover' => "this.src='".$OUTPUT->pix_url('t/aia/hide1')."'", 'onmouseout' => "this.src='".$OUTPUT->pix_url('t/aia/hide')."'", 'title' => get_string('active'), 'alt' => get_string('show'), 'class' => 'iconsmall'))); } } if ($checkpermissions || is_siteadmin()) { $action_buttons = implode(' ', $buttons); } else { $action_buttons = ""; } $extrainfo = "<ul id='costcenter-info'><li>Total employees: $employes_count</li><span class='liborder'></span>"; $extrainfo .= "<li>Training managers: $managers_count</li><span class='liborder'></span><li>Team managers: $tmanager_count </li><span class='liborder'></span><li>Courses: $course_count</li><span class='liborder'></span><li id='manager_list'>Managers: $managers_list</li></ul>"; $assignusers ="<div id='employeedialog$costcenter->id' class='dialog1' style='display:none;'>"; $assignusers .= $this->assign_employees($costcenter->id); $assignusers .='</div>'; $toggle = "<div id='dialog$costcenter->id' class='dialog1' style='display:none;'>"; $toggle .= $this->assign_manager($costcenter_instance,$costcenter->id); $toggle .="</div>"; $line[] = $this->display_department_item($costcenter, $showdepth) .'<span id="action_buttons">'. $action_buttons .'</span>'. $extrainfo . $assignusers . $toggle; $data[] = $line; //$cell = new html_table_cell($toggle); //$cell->colspan = 3; //$data[] = new html_table_row(array($cell)); //$data[] = array($toggle); } $table = new html_table(); if (has_capability('local/costcenter:manage', $systemcontext)) $table->head = array(''); $table->size = array('60%', '25%', '15%'); $table->align = array('left', 'left', 'center'); $table->width = '100%'; $table->data = $data; $table->id = 'department-index'; $table->attributes['class'] = 'tataaia_departs'; //@Harsha $output = html_writer::table($table); return $output; }
e.preventDefault(); $("#wrapper").toggleClass("toggled"); }); }); </script> <div id="page-content" class="row-fluid"> <div id="<?php echo $regionbsid ?>" class="span12"> <div class="row-fluid"> <!--span8 changed to span12 for the slider of blocks--> <section id="region-main" class="span12 pull-right"> <div id="header-notifications"> <?php require_once($CFG->dirroot.'/local/costcenter/lib.php'); $department=new costcenter(); foreach ( $department->get_confirmation() as $notice) { if (isset($notice['style'])) { notify($notice['message'], $notice['style']); } else { notify($notice['message']); } } unset($notice); ?> </div> <?php //$hide = ' hide_blocks'; echo $OUTPUT->course_content_header(); echo $OUTPUT->main_content();
$id = optional_param('id', -1, PARAM_INT); // user id; -1 if creating new tool $userid = optional_param('userid', 0, PARAM_INT); $delete = optional_param('delete', 0, PARAM_BOOL); $confirm = optional_param('confirm', 0, PARAM_BOOL); $hide = optional_param('hide', 0, PARAM_INT); $show = optional_param('show', 0, PARAM_INT); $visible = optional_param('visible', -1, PARAM_INT); $moveto = optional_param('moveto', 0, PARAM_INT); $sesskey = optional_param('sesskey', '', PARAM_RAW); $costcenterids = optional_param('id', 0, PARAM_INT); $unassign = optional_param('unassign', 0, PARAM_BOOL); $conf = new object(); require_login(); $costcenter = new costcenter(); if ($id > 0) { if (!($costcenter_instance = $DB->get_record('local_costcenter', array('id' => $id)))) { print_error('invalidtoolid1122', 'local_costcenter'); } } else { $costcenter_instance = new stdClass(); $costcenter_instance->id = -1; } $PAGE->set_url('/local/costcenter/costcenter.php'); $systemcontext = context_system::instance();
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); }