public function action_addtask($project_id) { if (!($project = Model_Project::find($project_id))) { \Fuel\Core\Session::set_flash('error', "Cannot find the selected project # {$project_id}"); \Fuel\Core\Response::redirect_back('user/projects'); } $val = Model_Projecttask::validate('create'); if (\Fuel\Core\Input::method() == 'POST') { if ($val->run()) { $projecttask = Model_Projecttask::forge(array('project_id' => Input::post('project_id'), 'user_id' => Input::post('user_id'), 'project_task_name_id' => Input::post('project_task_name_id'), 'hourly_rate' => Input::post('hourly_rate'), 'task_status' => 0, 'task_due' => Input::post('task_due'), 'project_task_description' => Input::post('project_task_description'), 'comment' => Input::post('comment'), 'priority' => Input::post('priority'))); if ($projecttask and $projecttask->save()) { Session::set_flash('success', e('Added task #' . $projecttask->id . '.')); Response::redirect('user/projects/view/' . $project_id); } else { Session::set_flash('error', e('Could not save task.')); } } else { \Fuel\Core\Session::set_flash('error', $val->error()); } } $this->load_presenter($project, Model_Projecttask::forge(array('id' => 0, 'project_id' => $project->id, 'user_id' => $this->current_user->id, 'task_status' => 0, 'hourly_rate' => 456, 'task_due' => date('Y-m-d')))); $this->template->set_global('project_task_names', Model_Projecttaskname::find('all', array('order_by' => array(array('name', 'asc'))))); $this->template->set_global('users', array(Model_User::find($this->current_user->id))); $this->template->set_global('priorities', THelper::get_priorities()); $this->template->title = 'My Projects'; $this->template->content = Fuel\Core\View::forge('user/projects/addtask'); }
public function action_login() { // already logged in? if (Auth::check()) { // yes, so go back to the page the user came from, or the // application dashboard if no previous page can be detected //Messages::info(__('login.already-logged-in')); Response::redirect_back(''); } // was the login form posted? if (Input::method() == 'POST') { // check the credentials. print_r(Input::all()); if (Auth::login(Input::param('email'), Input::param('password'))) { // did the user want to be remembered? if (Input::param('remember', false)) { // create the remember-me cookie Auth::remember_me(); } else { // delete the remember-me cookie if present Auth::dont_remember_me(); } // logged in, go back to the page the user came from, or the // application dashboard if no previous page can be detected Response::redirect_back('/home'); } else { // login failed, show an error message $this->error = 'test'; } } // display the login page return \View::forge('auth/login'); }
public function action_edit($id = null) { if (\Fuel\Core\Input::method() == 'POST') { $id = \Fuel\Core\Input::post('id'); } if (!($user = Model_User::find($id))) { \Fuel\Core\Session::set_flash('error', 'Could not find user # ' . $id); \Fuel\Core\Response::redirect('admin/users'); } $val = Model_User::validate('edit'); if (\Fuel\Core\Input::method() == 'POST') { if ($val->run()) { $user->username = \Fuel\Core\Input::post('username'); $user->email = \Fuel\Core\Input::post('email'); $user->group = \Fuel\Core\Input::post('group'); $user->first_name = \Fuel\Core\Input::post('first_name'); $user->last_name = \Fuel\Core\Input::post('last_name'); $user->target_billable = \Fuel\Core\Input::post('target_billable'); $user->target_unbillable = \Fuel\Core\Input::post('target_unbillable'); try { if ($user->save()) { Session::set_flash('success', e('Updated user #' . $id)); Response::redirect('admin/users'); } else { Session::set_flash('error', e('Could not update user #' . $id)); } } catch (\SimpleUserUpdateException $ex) { // duplicate email address if ($ex->getCode() == 2) { Fuel\Core\Session::set_flash('error', 'Email already exists.'); } elseif ($ex->getCode() == 3) { Fuel\Core\Session::set_flash('error', 'Username already exists.'); } else { Fuel\Core\Session::set_flash('error', $ex->getMessage()); } } } else { if (Input::method() == 'POST') { Session::set_flash('error', $val->error()); } } } $this->template->set_global('user', $user, false); $this->template->set_global('val', $val, false); $this->template->set_global('groups', $this->get_groups_list()); $this->template->title = "Users"; $this->template->content = View::forge('admin/users/edit'); }
/** * @author Thuanth6589 <*****@*****.**> * delete sssale */ public function action_delete() { if (Input::method() == 'POST') { $sssale_id = Input::post('sssale_id'); $result = 'error-' . Input::post('panel_index'); $message = \Constants::$message_delete_error; if (isset($sssale_id) && ($sssale = \Model_Sssale::find_by_pk($sssale_id))) { if ($sssale->delete_data()) { $result = 'success'; $message = \Constants::$message_delete_success; } } Session::set_flash($result, $message); } $url = Session::get('sssale_url') ? Session::get('sssale_url') : Uri::base() . 'master/sslist'; return Response::redirect($url); }
/** * @author Thuanth6589 <*****@*****.**> * action delete user */ public function action_delete() { if (Input::method() == 'POST') { $user_id = Input::post('user_id', null); $result = 'error'; if (!\Model_Muser::find_by_pk($user_id)) { $message = 'ユーザーは存在しません'; } else { $message = \Constants::$message_delete_error; $user = new \Model_Muser(); if ($user->delete_data($user_id)) { $result = 'success'; $message = \Constants::$message_delete_success; } } Session::set_flash($result, $message); } $url = Session::get('users_url') ? Session::get('users_url') : Uri::base() . 'master/users'; return Response::redirect($url); }
/** * @author Thuanth6589 <*****@*****.**> * action delete media */ public function action_delete() { if (Input::method() == 'POST') { $result = 'error'; $m_media_id = Input::post('m_media_id', null); if (!\Model_Mmedia::find_by_pk($m_media_id)) { $message = '媒体は存在しません'; } else { $umedia = new \Model_Umedia(); $message = \Constants::$message_delete_error; if ($umedia->delete_media($m_media_id)) { $result = 'success'; $message = \Constants::$message_delete_success; } } Session::set_flash($result, $message); } $url = Session::get('medias_url') ? Session::get('medias_url') : Uri::base() . 'master/medias'; return Response::redirect($url); }
/** * @author Thuanth6589 * action index */ public function action_index() { $data['person_id'] = Input::get('person_id', ''); $inteview_usami = new \Model_Interviewusami(); if ($data['person_id'] == '' || !\Model_Person::find($data['person_id'])) { return Response::redirect(Uri::base() . 'job/persons'); } $data['inteview_usami'] = \Model_Interviewusami::find_one_by('person_id', $data['person_id']); if (Input::method() == 'POST') { $fields = Input::post('data'); $inteview_usami->set_data($fields); if ($inteview_usami->save_data()) { Session::set_flash('success', \Constants::$message_create_success); return Response::redirect(Uri::base() . 'job/interviewusami?person_id=' . $data['person_id']); } Session::set_flash('error', \Constants::$message_create_error); } $this->template->title = 'UOS求人システム'; $this->template->content = View::forge('interviewusami/index', $data); }
public function action_index() { $this->template->title = 'UOS求人システム'; $data = array(); $data['file_name'] = ''; if (Input::method() == 'POST') { $arr_file = Input::file('csv'); if (substr($arr_file['name'], -4) == '.csv') { $data['file_name'] = $arr_file['name']; $import = new \Import(); $res = $import->update_csv($arr_file['tmp_name']); $data['no_update'] = $import->no_update; if ($res) { $data['success'] = true; } else { $data['error'] = $import->get_errors(); } } else { $data['error'] = array('CSVのフォーマットが正しくありません'); } } $this->template->content = \Fuel\Core\View::forge('jobup/index', $data); }
/** * @author NamDD <*****@*****.**> * get info car * @return \Response */ public function action_get_ss() { $group_id = null; $partner_code = null; if (\Fuel\Core\Input::method() == 'POST') { $group_id = \Fuel\Core\Input::post('group_id', null); $partner_code = \Fuel\Core\Input::post('partner_code', null); } else { $group_id = \Fuel\Core\Input::get('group_id', null); $partner_code = \Fuel\Core\Input::get('partner_code', null); } $data = (new \Model_Mss())->get_data(array('group_id' => $group_id, 'partner_code' => $partner_code))->as_array(); $res = array(); if (count($data)) { $i = 0; foreach ($data as $row) { $res[$i]['ss_id'] = $row->ss_id; $res[$i]['ss_name'] = $row->ss_name; ++$i; } } return new \Response(json_encode($res), 200, array()); }
public function action_fields($id, $type) { $pass = Model_Pass::find($id); if (\Fuel\Core\Input::method() == 'POST') { if ($type == 'primary') { $pass->set_primary_field(\Fuel\Core\Input::post('label', ''), \Fuel\Core\Input::post('value', '')); Session::set_flash('success', e('Added ' . $type . ' field.')); } else { $pass->set_field(Model_Field::string2type($type), \Fuel\Core\Input::post('key', ''), \Fuel\Core\Input::post('label', ''), \Fuel\Core\Input::post('value', ''), \Fuel\Core\Input::post('others', '')); Session::set_flash('success', e('Added ' . $type . ' field.')); \Fuel\Core\Response::redirect('admin/pass/fields/' . $pass->id . '/' . $type); } } if ($type == 'primary') { $this->template->set_global('field', $pass->primary_field(), false); $this->template->content = View::forge('admin/pass/primaryfields'); } else { $this->template->set_global('fields', $pass->{$type . '_fields'}(), false); $this->template->content = View::forge('admin/pass/fields'); } $this->template->set_global('type', $type, false); $this->template->set_global('pass', $pass, false); $this->template->title = "Pass " . $type . ' fields'; }
public function action_create($what = null) { is_null($what) and \Fuel\Core\Response::redirect('filemanager'); try { if (\Fuel\Core\Input::method() == 'POST') { if ($what == 'dir') { $dir = \Fuel\Core\File::create_dir('/var/www/html/' . $this->_dir . '/', \Fuel\Core\Input::post('dir_name'), 0777); if ($dir) { \Fuel\Core\Response::redirect('filemanager'); } } } } catch (Exception $e) { die($e->getMessage()); } \Fuel\Core\Response::redirect('filemanager'); }
public function action_index() { $data = array(); $ujob_obj = new \Model_Ujob(); $job_id = \Fuel\Core\Input::get('job_id', ''); $copy_job_id = \Fuel\Core\Input::get('copy_job_id', ''); $job_id_get_data = $copy_job_id ? $copy_job_id : $job_id; $data_default = $ujob_obj->get_info_job($job_id_get_data); if ($data_default['job_id'] == null && $job_id) { \Fuel\Core\Response::redirect(\Fuel\Core\Uri::base() . 'job/job'); } if ($copy_job_id) { $data_default['edit_data'] = null; } $data = $data_default; $data['old_data'] = $data_default; $data['old_data']['job_add'] = array(); $data['old_data']['job_recruit'] = array(); $data['old_data']['m_image'] = array(); $data['job_add'] = array(); $data['job_recruit'] = array(); $data['m_image'] = array(); $label = array('group' => 'グループ', 'partner' => '取引先(受注先)', 'ss' => 'SS', 'sslist' => '売上形態'); $data_filter['field'] = array('step' => 4, 'type' => 1, 'label' => $label); if (\Fuel\Core\Input::method() == 'POST') { $data_post = \Fuel\Core\Input::post(); if (!isset($data_post['employment_mark'])) { $data_post['employment_mark'] = array(); } if (!isset($data_post['work_time_view'])) { $data_post['work_time_view'] = array(); } if (!isset($data_post['trouble'])) { $data_post['trouble'] = array(); } $check = true; if (!\Model_Sssale::find_by_pk($data_post['sssale_id'])) { \Fuel\Core\Session::set_flash('report', '売上形態は存在しません'); $check = false; } foreach ($data_post['media_list'] as $k => $v) { if ($v == '') { unset($data_post['media_list'][$k]); continue; } if (!\Model_Mmedia::find_by_pk($v)) { \Fuel\Core\Session::set_flash('report', '媒体は存在しません'); $check = false; break; } } if ($check) { $this->save($ujob_obj, $job_id, $data_post); } } if ($data_default['edit_data']) { $data = json_decode($data_default['edit_data'], true); $data_default_edit = $ujob_obj->get_info_job(''); $data = $data + $data_default_edit; $data = \Utility::set_standard_data_job($data, false); $ujob_obj->convert_job_add_recruit($data); $data['m_image'] = $ujob_obj->get_list_m_image($data['image_list']); /*Get old data*/ $data['old_data'] = $data_default; $data['old_data']['job_add'] = $ujob_obj->get_list_job_add($job_id); $data['old_data']['job_recruit'] = $ujob_obj->get_list_job_recruit($job_id); $data['old_data']['m_image'] = $ujob_obj->get_list_m_image($data['old_data']['image_list']); } else { if ($job_id_get_data) { $data['job_add'] = $ujob_obj->get_list_job_add($job_id_get_data); $data['job_recruit'] = $ujob_obj->get_list_job_recruit($job_id_get_data); $data['m_image'] = $ujob_obj->get_list_m_image($data['image_list']); $data['old_data']['job_add'] = $data['job_add']; $data['old_data']['job_recruit'] = $data['job_recruit']; $data['old_data']['m_image'] = $data['m_image']; } } $data['is_show_old'] = array(); if ($job_id) { $data['is_show_old'] = $this->_compare_other_data_json($data['old_data'], $data_default['edit_data']); } $data_filter['datafilter'] = \Presenter_Group_Filter::edit($data_filter['field']['step'], $data_filter['field']['type'], $data['sssale_id'], $data['old_data']['sssale_id']); $data['interview_des'] = '面接は勤務地または近隣にて行います。'; $data['apply_method'] = '下記のフリーダイヤルまたは「応募する」ボタンより、応募シートに必要事項を入力の上、送信して下さい。※応募書類は返却致しません。ご了承ください。'; $data['apply_process'] = '追って、こちらからご連絡差し上げます。※ご連絡は平日に致します。★ネット応募は24h受付中!!'; $this->template->title = 'UOS求人システム'; $this->template->content = \Fuel\Core\View::forge('job/index', $data); $this->template->content->filtergroup = \Presenter::forge('group/filter')->set('custom', $data_filter); }
public function action_forgot() { \Auth\Auth::check() and \Fuel\Core\Response::redirect("user"); $val = \Fuel\Core\Validation::forge('forgot'); if (\Fuel\Core\Input::method() == "POST") { if ($val->run()) { try { $username = \Fuel\Core\Input::post('email'); $user = Model_User::find('first', array('where' => array(array('username', 'LIKE', "{$username}"), 'or' => array(array('email', 'LIKE', "{$username}"))))); if (!$user) { throw new \Auth\SimpleUserUpdateException("Invalid username or email"); } $old_password = \Auth\Auth::reset_password($user->username); $new_password = \Fuel\Core\Str::random(); \Auth\Auth::update_user(array('password' => $new_password, 'old_password' => $old_password), $user->username); // Create an instance $email = \Email\Email::forge(); // Set the from address $email->from('*****@*****.**', 'ITNT Time Sheets'); // Set the to address $email->to($user->email, $user->first_name . " " . $user->last_name); // Set a subject $email->subject('ITNT Time Sheets Password Reset'); // Set multiple to addresses // $email->bcc(array( // '*****@*****.**' => 'Gavin Murambadoro', // )); // Set a html body message $email->html_body(\View::forge('includes/email/forgot', array('user' => $user, 'password' => $new_password))); if ($email->send()) { $this->template->set_global('login_success', "Your password has been reset and an email was sent to {$user->email}"); } else { $this->template->set_global('login_error', "Your password was reset but we could not send you an email. Your new password is {$new_password}. Make sure that you copy this before leaving this page."); } } catch (\SimpleUserUpdateException $exception) { $this->template->set_global('login_error', "User Error: {$exception->getMessage()}"); } catch (\EmailValidationFailedException $exception) { $this->template->set_global('login_error', "Mail Validation Error: {$exception->getMessage()}"); } catch (\EmailSendingFailedException $exception) { $this->template->set_global('login_error', "Mail Error: {$exception->getMessage()}"); } catch (Exception $exception) { $this->template->set_global('login_error', "General Error: {$exception->getMessage()}"); } } else { $this->template->set_global('login_error', $val->error()); } } $this->template->set_global('val', $val, false); $this->template->title = 'Forgot Password'; $this->template->content = View::forge('user/forgot'); }
public function action_accountMultisite() { $act = trim(\Input::post('act')); $output = []; if (strtolower(\Fuel\Core\Input::method()) == 'post') { if ($act == 'createmaintable') { $create_table = \Fuel\Core\DBUtil::create_table('testmultisiteaccount', ['id' => ['constraint' => 11, 'type' => 'int', 'auto_increment' => true], 'account_id' => ['constraint' => 11, 'type' => 'int', 'null' => true, 'comment' => 'refer to accounts.account_id'], 'actdate' => ['type' => 'bigint', 'null' => true, 'comment' => 'date/time of record date.']], ['id'], true); $output['create_table_result'] = $create_table; $output['result'] = true; } elseif ($act == 'insertdemodata') { // get accounts that is not guest $account_result = \DB::select('account_id')->as_object()->from('accounts')->where('account_id', '!=', '0')->execute(); // get all sites from site table $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute(); $output['tables_data'] = []; if ($sites_result != null) { foreach ($sites_result as $site) { if ($site->site_id == '1') { $test_table = 'testmultisiteaccount'; } else { $test_table = $site->site_id . '_testmultisiteaccount'; } if (\DBUtil::table_exists($test_table)) { \DBUtil::truncate_table($test_table); if ($account_result != null) { foreach ($account_result as $account) { \DB::insert($test_table)->set(['account_id' => $account->account_id, 'actdate' => time()])->execute(); } // endforeach; $account_result } // endif; $account_result // finished insert get data from this table. $this_table_result = \DB::select()->as_object('stdClass')->from($test_table)->limit(10)->order_by('id', 'DESC')->execute()->as_array(); $output['tables_data'][$test_table] = $this_table_result; unset($this_table_result); } unset($test_table); } // endforeach; $sites_result $output['result'] = true; } // endif; $sites_result unset($account, $account_result, $site, $sites_result); } elseif ($act == 'loaddemodata') { // get all sites from site table $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute(); $output['tables_data'] = []; if ($sites_result != null) { foreach ($sites_result as $site) { if ($site->site_id == '1') { $test_table = 'testmultisiteaccount'; } else { $test_table = $site->site_id . '_testmultisiteaccount'; } if (\DBUtil::table_exists($test_table)) { $this_table_result = \DB::select()->as_object('stdClass')->from($test_table)->limit(10)->order_by('id', 'DESC')->execute()->as_array(); $output['tables_data'][$test_table] = $this_table_result; unset($this_table_result); } } // endforeach; $sites_result $output['result'] = true; } // endif; $sites_result unset($site, $sites_result); } elseif ($act == 'droptable') { // get all sites from site table $sites_result = \DB::select('site_id')->as_object()->from('sites')->execute(); if ($sites_result != null) { foreach ($sites_result as $site) { if ($site->site_id == '1') { $test_table = 'testmultisiteaccount'; } else { $test_table = $site->site_id . '_testmultisiteaccount'; } if (\DBUtil::table_exists($test_table)) { \DBUtil::drop_table($test_table); } } // endforeach; $sites_result $output['result'] = true; } // endif; $sites_result unset($site, $sites_result); } // endif; $act if (\Input::is_ajax()) { $response = new \Response(); // no cache $response->set_header('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate'); $response->set_header('Cache-Control', 'post-check=0, pre-check=0', false); $response->set_header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT'); $response->set_header('Pragma', 'no-cache'); // content type $response->set_header('Content-Type', 'application/json'); // set body if ($output == null) { $output = []; } $response->body(json_encode($output)); return $response; } } // <head> output ------------------------------------------- $output['page_title'] = $this->generateTitle('Test module plugin'); // <head> output ------------------------------------------- // breadcrumb ------------------------------------------------------------------------------------------------- $page_breadcrumb = []; $page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')]; $page_breadcrumb[1] = ['name' => 'Test module plugin', 'url' => \Uri::create('testmod/admin/index')]; $page_breadcrumb[2] = ['name' => 'Test delete account on multisite table', 'url' => \Uri::main()]; $output['page_breadcrumb'] = $page_breadcrumb; unset($page_breadcrumb); // breadcrumb ------------------------------------------------------------------------------------------------- return $this->generatePage('admin/templates/index/accountMultisite_v', $output, false); }
/** * @author Thuanth6589 <*****@*****.**> * action delete ss */ public function action_delete() { if (Input::method() == 'POST') { $ss_id = Input::post('ss_id', null); $result = 'error'; if (!\Model_Mss::find_by_pk($ss_id)) { $message = 'SSは存在しません'; } else { $message = \Constants::$message_delete_error; if (\Model_Uss::delete_ss($ss_id)) { $result = 'success'; $message = \Constants::$message_delete_success; } } Session::set_flash($result, $message); } $url = Session::get('sslist_url') ? Session::get('sslist_url') : Uri::base() . 'master/sslist'; return Response::redirect($url); }