Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /proc/self/root/var/www/blue-sky.co.id/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Career extends Admin_Controller { function __construct() { parent::__construct(); } public function index() { //pagination in action. 20 results per page $this->load->library('pagination'); $config['base_url'] = base_url() . 'admin/career/index'; $config['per_page'] = 20; $config["uri_segment"] = 4; $config['total_rows'] = $this->db->get("career")->num_rows(); $this->pagination->initialize($config); $this->data['career'] = $this->db->select("*")->from("career")->limit($config["per_page"], $this->uri->segment(4))->get()->result(); //load view $this->data['subview'] = 'admin/career/index'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } function career_type_save(){ $inp_name = $this->input->post('name'); $id = $this->input->post('id'); if (!$inp_name) { show_404(); } if ($id) { $data_ins = array( "name"=>$inp_name ); $this->db->where('id', $id); $this->db->update('career_type', $data_ins); }else{ $data_ins = array( "name"=>$inp_name ); $this->db->insert('career_type', $data_ins); } $data_op = array( "alert_op" => '<p style="background:green; color:white; padding:5px; font-weight:bold;">Tipe Career berhasil di simpan</p>', "data_op" => $this->output_type_career()['table'], "data_dd" => $this->output_type_career()['dropdown'], ); echo json_encode($data_op); } function output_type_career(){ $q_career_type = $this->db->get("career_type")->result(); $op_career_type = ''; $drop_down = array(); foreach ($q_career_type as $key): $drop_down[] = array( "id"=>$key->id, "name"=>$key->name, ); $op_career_type .= '<tr> <td> '.ucwords($key->name).' </td> <td style="text-align: center;"> <button onclick="btn_tipe_edit($(this));" data-id="'.$key->id.'" type="button" class="btn_tipe_edit btn btn-sm btn-default"> <i class="fa fa-pencil-square-o"></i> </button> | <button onclick="btn_tipe_delete($(this));" data-id="'.$key->id.'" type="button" class="btn_tipe_delete btn btn-sm btn-default"> <i class="fa fa fa-trash-o"></i> </button> </td> </tr>'; endforeach; return array( "table"=>$op_career_type, "dropdown"=>$drop_down, ); } function career_type_delete(){ $id = $this->input->post('id'); if (!$id) { show_404(); } $this->db->where('id', $id); $this->db->delete("career_type"); $data_op = array( "alert_op" => '<p style="background:green; color:white; padding:5px; font-weight:bold;">Tipe Career berhasil di hapus</p>', "data_op" => $this->output_type_career()['table'], "data_dd" => $this->output_type_career()['dropdown'], ); echo json_encode($data_op); } public function delete($id) { $quer_career = $this->db->get_where("career",array( "id"=>$id )); if ($quer_career->num_rows() == 0) { //page not exist show_404(); } $this->db->where('id', $id); $this->db->delete("career"); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hapus Career Berhasil</p>'); redirect('admin/career'); } public function add() { $career = new stdClass(); $career->name = ''; $career->career_type = ''; $career->active = 'yes'; $career->detail_reqs = '-'; $this->data['pages'] = $career; //validation in action //validation check in action $config = array( array( 'field' => 'inp_name', 'label' => 'Name Career', 'rules' => 'trim|required' ), array( 'field' => 'detail_reqs', 'label' => 'Detail Requirements', 'rules' => 'trim' ), ); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run($this) == TRUE) { $data = array( 'name' => $this->security->xss_clean($this->input->post('inp_name')), 'career_type' => $this->input->post('career_type'), 'detail_reqs' => $this->input->post('detail_reqs'), 'active' => $this->input->post('status'), ); $this->db->insert('career', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Tambah Career Berhasil</p>'); redirect('admin/career'); } $this->data['subview'] = 'admin/career/edit'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } public function edit($id = NULL) { $quer_career = $this->db->get_where("career",array( "id"=>$id )); if ($quer_career->num_rows() == 0) { //page not exist show_404(); } $this->data['career'] = $quer_career->row(); //validation check in action $config = array( array( 'field' => 'inp_name', 'label' => 'Name Career', 'rules' => 'trim|required' ), array( 'field' => 'detail_reqs', 'label' => 'Detail Requirements', 'rules' => 'trim' ), ); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run($this) == TRUE) { $data = array( 'name' => $this->security->xss_clean($this->input->post('inp_name')), 'career_type' => $this->input->post('career_type'), 'detail_reqs' => $this->input->post('detail_reqs'), 'active' => $this->input->post('status'), ); $this->db->where('id', $id); $this->db->update('career', $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Edit Career Berhasil</p>'); redirect('admin/career/edit/' . $id); } $this->data['subview'] = 'admin/career/edit'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } function changeStatusAct(){ $this_id = $this->input->post('this_id'); $toStat = $this->input->post('toStat'); $codeStat = null; if ($toStat == "Ya") { $codeStat = 'yes'; }else{ $codeStat = 'no'; } $data = array( "active"=>$codeStat, ); $upd = $this->db->update('career', $data, array('id' => $this_id)); if ($upd) { echo json_encode(array( "res"=>"sukses", )); } } }