%PDF-1.4
Directory : /var/www/vhosts/lautnusantara.com/httpdocs/mis/app/Controllers/ |
<?php namespace App\Controllers; use CodeIgniter\Controller; use App\Models\Menu_Model; use App\Models\Menu_Type_Model; use App\Models\Menu_Group_Model; // use App\Models\History_model; class Menu extends BaseController { protected $History; protected $session; protected $Menu_Model; protected $Menu_type_Model; protected $Menu_group_Model; public function __construct() { // $this->History = new History_model(); $this->Menu_Model = new Menu_Model(); $this->Menu_type_Model = new Menu_type_Model(); $this->Menu_group_Model = new Menu_group_Model(); $this->session = session(); } public function index() { $user_id = session()->get('user_id'); $username = session()->get('username'); $firstname = session()->get('firstname'); $lastname = session()->get('lastname'); // $this->History->save([ // 'user_id' => $user_id, // 'username' => $username, // 'name' => $firstname.' '.$lastname, // 'kegiatan' => 'Dashboard', // 'jenis_kegiatan' => 'Login/Dashboard', // 'tanggal_waktu' => date('Y-m-d H:i:s') // ]); // $this->data_dashboard = new DashboardModel(); $data = array( 'title' => 'MCS - Manajemen Compro System', 'description' => 'Aplikasi MCS - Manajemen Compro System', 'keywords' => 'MCS, Manajemen, Compro', 'author' => 'SSN', 'parent_id_menu' => '18', 'parent_id_submenu' => '22', 'id_menu' => '25', 'page1' => 'Menu', 'page2' => '', 'link01' => base_url() . '/menu', 'link02' => '', 'data_menu' => $this->Menu_Model->get_all_menu()->getResultArray(), 'componen' => 'theme/BeyondAdmin/halaman/setting/menu/daftar_menu' ); echo view('layout', $data); } public function add() { $user_id = session()->get('user_id'); $username = session()->get('username'); $firstname = session()->get('firstname'); $lastname = session()->get('lastname'); // $this->History->save([ // 'user_id' => $user_id, // 'username' => $username, // 'name' => $firstname.' '.$lastname, // 'kegiatan' => 'Dashboard', // 'jenis_kegiatan' => 'Login/Dashboard', // 'tanggal_waktu' => date('Y-m-d H:i:s') // ]); // $this->data_dashboard = new DashboardModel(); $data = array( 'title' => 'MCS - Manajemen Compro System', 'description' => 'Aplikasi MCS - Manajemen Compro System', 'keywords' => 'MCS, Manajemen, Compro', 'author' => 'SSN', 'parent_id_menu' => '18', 'parent_id_submenu' => '22', 'id_menu' => '25', 'page1' => 'Add Menu', 'page2' => 'Menu', 'link01' => base_url() . '/menu/add', 'link02' => base_url() . '/menu', 'dt_title' => old('dt_title'), 'icon' => old('icon'), 'parent_id' => old('parent_id'), 'sortir' => old('sortir'), 'link' => old('link'), 'have_child' => old('have_child'), 'groupmenu_id' => old('groupmenu_id'), 'typemenu_id' => old('typemenu_id'), 'active' => 0, 'id' => 0, 'status' => 'add', 'url_form' => base_url('menu/save'), 'data_menu_type' => $this->Menu_type_Model->get_list_menu_type()->getResultArray(), 'data_menu_group' => $this->Menu_group_Model->get_list_menu_group()->getResultArray(), 'data_parent_menu' => $this->Menu_Model->get_parent_menu()->getResultArray(), 'componen' => 'theme/BeyondAdmin/halaman/setting/menu/add_menu' ); echo view('layout', $data); } public function edit($id) { $user_id = session()->get('user_id'); $username = session()->get('username'); $firstname = session()->get('firstname'); $lastname = session()->get('lastname'); // $this->History->save([ // 'user_id' => $user_id, // 'username' => $username, // 'name' => $firstname.' '.$lastname, // 'kegiatan' => 'Dashboard', // 'jenis_kegiatan' => 'Login/Dashboard', // 'tanggal_waktu' => date('Y-m-d H:i:s') // ]); // $this->data_dashboard = new DashboardModel(); $dt_menu = $this->Menu_Model->get_detail_menu($id)->getResult(); $data = array( 'title' => 'MCS - Manajemen Compro System', 'description' => 'Aplikasi MCS - Manajemen Compro System', 'keywords' => 'MCS, Manajemen, Compro', 'author' => 'SSN', 'parent_id_menu' => '18', 'parent_id_submenu' => '22', 'id_menu' => '25', 'page1' => 'Edit Menu', 'page2' => 'Menu', 'link01' => base_url() . '/menu/edit', 'link02' => base_url() . '/menu', 'dt_title' => $dt_menu[0]->title, 'icon' => $dt_menu[0]->icon, 'parent_id' => $dt_menu[0]->parent_id, 'sortir' => $dt_menu[0]->sortir, 'link' => $dt_menu[0]->link, 'have_child' => $dt_menu[0]->have_child, 'groupmenu_id' => $dt_menu[0]->groupmenu_id, 'typemenu_id' => $dt_menu[0]->typemenu_id, 'active' => $dt_menu[0]->active, 'id' => $dt_menu[0]->id, 'status' => 'edit', 'url_form' => base_url('menu/update'), 'data_menu_type' => $this->Menu_type_Model->get_list_menu_type()->getResultArray(), 'data_menu_group' => $this->Menu_group_Model->get_list_menu_group()->getResultArray(), 'data_parent_menu' => $this->Menu_Model->get_parent_menu()->getResultArray(), 'componen' => 'theme/BeyondAdmin/halaman/setting/menu/add_menu' ); echo view('layout', $data); } public function save() { if ( !$this->validate([ 'dt_title' => [ 'rules' => 'required|min_length[3]', 'error' => [ 'required' => 'Title type Harus diisi' ] ] ]) ) { session()->setFlashdata('error', $this->validator->listErrors()); return redirect()->back()->withinput(); } else { $active = 0; if (!is_null($this->request->getVar('active'))) { $active = 1; } $have_child = 0; if (!is_null($this->request->getVar('have_child'))) { $have_child = 1; } $data = array( 'title' => $this->request->getVar('dt_title'), 'icon' => $this->request->getVar('icon'), 'parent_id' => $this->request->getVar('parent_id'), 'sortir' => $this->request->getVar('sortir'), 'link' => $this->request->getVar('link'), 'have_child' => $have_child, 'typemenu_id' => $this->request->getVar('typemenu_id'), 'groupmenu_id' => $this->request->getVar('groupmenu_id'), 'active' => $active, ); $this->Menu_Model->save_menu($data); return redirect()->to(base_url('menu')); } } public function update() { if ( !$this->validate([ 'dt_title' => [ 'rules' => 'required|min_length[3]', 'error' => [ 'required' => 'Nama type Harus diisi' ] ] ]) ) { session()->setFlashdata('error', $this->validator->listErrors()); return redirect()->back()->withinput(); } else { $active = 0; if (!is_null($this->request->getVar('active'))) { $active = 1; } $have_child = 0; if (!is_null($this->request->getVar('have_child'))) { $have_child = 1; } $id = $this->request->getVar('id'); $data = array( 'title' => $this->request->getVar('dt_title'), 'icon' => $this->request->getVar('icon'), 'parent_id' => $this->request->getVar('parent_id'), 'sortir' => $this->request->getVar('sortir'), 'link' => $this->request->getVar('link'), 'have_child' => $have_child, 'typemenu_id' => $this->request->getVar('typemenu_id'), 'groupmenu_id' => $this->request->getVar('groupmenu_id'), 'active' => $active, ); $this->Menu_Model->update_menu($data, $id); return redirect()->to(base_url('menu')); } } public function delete($id) { $data = array( 'trash' => 1, ); $this->Menu_Model->update_menu($data, $id); return redirect()->to(base_url('menu')); } function edit_active() { $id = $this->request->getVar('ids'); $active = 0; if (!is_null($this->request->getVar('active'))) { $active = 1; } $data = array( 'active' => $active, ); //return redirect()->to(base_url()); var_dump($data); die; $this->Menu_Model->update_menu($data, $id); // return redirect()->to(base_url('menu_type')); } function simpan_active() { $id = $this->request->getVar('ids'); $active = $this->request->getVar('cek'); $data = array( 'active' => $active, ); $this->Menu_Model->update_menu($data, $id); } } ?>