public static function get_employee($id) { $query = DB::select('employees.*', 'users.username', 'users.last_login', 'users.fb_login')->from('employees')->join('users', 'inner')->on('employees.user_id', '=', 'users.id')->where('employees.id', '=', $id)->execute()->as_array(); if (count($query)) { $result = $query[0]; $result['custom'] = Model_EmployeeCustom::get_employee_custom($id); $result['expect'] = Model_Expect::get_expects($id); $result['experience'] = Model_Experience::get_experience($id); $result['school'] = Model_School::get_schools($id); $result['comp_skills'] = Model_Skill::get_computer_skills($id); $result['lang_skills'] = Model_Skill::get_language_skills($id); $result['other_skills'] = Model_Skill::get_other_skills($id); return $result; } else { return null; } }
public function action_addStaffPick($id) { is_null($id) and Response::redirect('employee'); $employee = Model_Employee::find($id); if (Input::method() == "POST") { try { $file = Input::file('pick_photo_file'); $config = array('path' => "/var/www/html/uploads/staffpick_cover/", 'ext_whitelist' => array('jpg', 'jpeg', 'png'), 'file_chmod' => 0777, 'auto_rename' => true, 'overwrite' => true, 'randomize' => true, 'create_path' => true); Upload::process($config); if (Upload::is_valid()) { Upload::save(); $pick_photo = Upload::get_files()[0]; $pick = Model_EmployeePick::forge(array('employee_id' => Input::post('employee_id'), 'pick_type' => Input::post('pick_type'), 'pick_date' => Input::post('pick_date'), 'pick_photo' => $pick_photo ? $pick_photo['saved_as'] : "", 'pick_is_active' => Input::post('pick_is_active'), 'created_at' => time())); if ($pick && $pick->save()) { $titles = Input::post('skill_title'); $levels = Input::post('skill_level'); foreach ($titles as $key => $val) { if (!strlen($val)) { continue; } $skill = Model_EmployeePickSkill::forge(array('pick_id' => $pick->id, 'skill_title' => $val, 'skill_level' => $levels[$key], 'created_at' => time())); $skill->save(); } Session::set_flash('success', 'Added employee #' . $id . ' to Staff Picks.'); Response::redirect('employee/staffPicks'); } else { Session::set_flash('error', 'Could not save employee pick.'); } } } catch (Exception $e) { die($e->getMessage()); } } $data['employee'] = $employee; $skills = Model_Skill::get_computer_skills($id); $data['skills'] = $skills; $this->theme->set_template('edit'); $this->theme->get_template()->set_global('employee', $employee, false); $this->theme->get_template()->set_global('skills', $skills, false); $this->theme->get_template()->set_global('provinces', Model_Province::get_provinces('th')); $this->theme->get_template()->set_global('current_menu', "Employees"); $this->theme->get_template()->set_global('current_menu_desc', "จัดการผู้ใช้งานที่เป็นผู้หางานทั้งหมดในระบบ"); $this->theme->get_template()->set('breadcrumb', array(array('title' => "Home", 'icon' => "fa-home", 'link' => Uri::create('home'), 'active' => false), array('title' => "Employees", 'icon' => "fa-users", 'link' => Uri::create('employee'), 'active' => false), array('title' => "Add Staff Pick", 'icon' => "fa-plus", 'link' => "", 'active' => true))); $this->theme->set_partial('sidebar', 'common/sidebar'); $this->theme->set_partial('left', 'employee/add_staff_pick')->set($data); }