%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/Perusahaan.php
<?php

namespace App\Controllers;

use CodeIgniter\Controller;

// use App\Models\DashboardModel;
use App\Models\History_model;
use App\Models\Perusahaan_Model;

class Perusahaan extends BaseController
{
    protected $History;
    protected $session;
    protected $Perusahaan_Model;

    public function __construct()
    {
        $this->History = new History_model();
        $this->session = session();
        $this->Perusahaan_Model = new Perusahaan_Model();
    }

    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' => '11',
            'parent_id_submenu' => '',
            'id_menu' => '35',
            'page1' => 'Add Perusahaan',
            'page2' => 'Perusahaan',
            'link01' => base_url() . '/perusahaan/add',
            'link02' => base_url() . '/perusahaan',
            'title' => old('title'),
            'introtext' => old('introtext'),
            'active' => 0,
            'id' => 0,
            'status' => 'add',
            'url_form' => base_url('perusahaan/save'),

            'componen' => 'theme/BeyondAdmin/halaman/modul/perusahaan/add'
        );
        echo view('layout', $data);
    }

    public function index()
    {
        $user_id = session()->get('user_id');
        $username = session()->get('username');
        $firstname = session()->get('firstname');
        $lastname = session()->get('lastname');

        $id = 1;
        // $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_perusahaan = $this->Perusahaan_Model->get_data($id)->getResult();

        $data = array(
            'title' => 'MCS - Manajemen Compro System',
            'description' => 'Aplikasi MCS - Manajemen Compro System',
            'keywords' => 'MCS, Manajemen, Compro',
            'author' => 'SSN',
            'parent_id_menu' => '11',
            'parent_id_submenu' => '',
            'id_menu' => '35',
            'page1' => 'Edit Perusahaan',
            'page2' => 'Perusahaan',
            'link01' => base_url() . '/perusahaan/edit',
            'link02' => base_url() . '/perusahaan',
            'nama' => $dt_perusahaan[0]->nama,
            'alamat' => $dt_perusahaan[0]->alamat,
            'telp' => $dt_perusahaan[0]->telp,
            'telp2' => $dt_perusahaan[0]->telp2,
            'telp3' => $dt_perusahaan[0]->telp3,
            'telp4' => $dt_perusahaan[0]->telp4,
            'telp5' => $dt_perusahaan[0]->telp5,
            'cs' => $dt_perusahaan[0]->cs,
            'cs2' => $dt_perusahaan[0]->cs2,
            'cs3' => $dt_perusahaan[0]->cs3,
            'cs4' => $dt_perusahaan[0]->cs4,
            'cs5' => $dt_perusahaan[0]->cs5,
            'jenis_wa' => $dt_perusahaan[0]->jenis_wa,
            'fax' => $dt_perusahaan[0]->fax,
            'email' => $dt_perusahaan[0]->email,
            'email2' => $dt_perusahaan[0]->email2,
            'email3' => $dt_perusahaan[0]->email3,
            'email4' => $dt_perusahaan[0]->email4,
            'email5' => $dt_perusahaan[0]->email5,
            'copyright' => $dt_perusahaan[0]->copyright,
            'url' => $dt_perusahaan[0]->url,
            'id' => $dt_perusahaan[0]->id,
            'logo' => $dt_perusahaan[0]->logo,
            'favicon' => $dt_perusahaan[0]->favicon,
            'data_baru' => 'T',
            'status' => 'edit',
            'url_form' => base_url('perusahaan/update'),

            'componen' => 'theme/BeyondAdmin/halaman/modul/perusahaan/add'
        );
        echo view('layout', $data);
    }

    public function save()
    {
        if (
            !$this->validate([
                'title' => [
                    'rules' => 'required|min_length[3]',
                    'error' => [
                        'required' => 'Kontak Kami Category 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(
                'title' => $this->request->getVar('title'),
                'introtext' => $this->request->getVar('introtext'),
                'active' => $active,
            );

            $this->Tentang_kami_Model->save_tentang_kami($data);

            return redirect()->to(base_url('tentang_kami'));
        }
    }

    public function update()
    {
        if (
            !$this->validate([
                'nama' => [
                    'rules' => 'required|min_length[3]',
                    'error' => [
                        'required' => 'Nama Harus diisi'
                    ]
                ]
            ])
        ) {
            session()->setFlashdata('error', $this->validator->listErrors());
            return redirect()->back()->withinput();
        } else {

            $username = session()->get('username');
            $user_id = session()->get('user_id');
            $published = 0;
            // $this->request->getVar('active');

            $id = $this->request->getVar('id');

            // $title = str_replace('"',"'",$this->request->getVar('title'));
            // $alias = $this->get_title_to_alias($title);

            //--- cek image ----
            $fileImage = $this->request->getFile('image');
            $fileFavicon = $this->request->getFile('favicon');

            $date = date_create();
            $tahun = date_format($date, "Y");
            $bulan = date_format($date, "m-M");
            $base_root = "/var/www/vhosts/lautnusantara.com/httpdocs";
            $folder_image = "/storage/images/perusahaan/";

            $imageLama = $this->request->getVar('sampulLama');
            $faviconLama = $this->request->getVar('faviconLama');

            // cek gambar lama
            if ($fileImage->getError() == 4) {
                $namaImage = $this->request->getVar('sampulLama');
            } else if ($this->request->getVar('sampulLama') == null) {
                // generate nama file random
                $namaImage = $fileImage->getName();
                // $namaImage = $fileImage->getRandomName();
                // pindahkan gambar
                $fileImage->move($base_root . $folder_image, $namaImage);
            } else if ($fileImage != null) {
                // generate nama file random
                $namaImage = $fileImage->getName();
                // pindahkan gambar
                $fileImage->move($base_root . $folder_image, $namaImage);
                // unlink('images/user/'. $this->request->getVar('sampulLama'));
            }

            if ($namaImage == null or $namaImage == "") {
                $url_image = $this->request->getVar('sampulLama');
            } else {
                if ($imageLama == NULL or $imageLama = '') {
                    $url_image = $folder_image . $namaImage;
                } else {
                    if (substr($namaImage, 0, 9) == substr($folder_image, 0, 9)) {
                        $url_image = $namaImage;
                    } else {
                        $url_image = $folder_image . $namaImage;
                    }
                }
            }

            //----- Favicon -------

            // cek gambar lama
            if ($fileFavicon->getError() == 4) {
                $namaFavicon = $this->request->getVar('faviconLama');
            } else if ($this->request->getVar('faviconLama') == null) {
                // generate nama file random
                $namaFavicon = $fileFavicon->getName();
                // $namaFavicon = $fileFavicon->getRandomName();
                // pindahkan gambar
                $fileFavicon->move($base_root . $folder_image, $namaFavicon);
            } else if ($fileFavicon != null) {
                // generate nama file random
                $namaFavicon = $fileFavicon->getName();
                // pindahkan gambar
                $fileFavicon->move($base_root . $folder_image, $namaFavicon);
                // unlink('images/user/'. $this->request->getVar('faviconLama'));
            }

            if ($namaFavicon == null or $namaFavicon == "") {
                $url_favicon = $this->request->getVar('faviconLama');
            } else {
                if ($faviconLama == NULL or $faviconLama = '') {
                    $url_favicon = $folder_image . $namaFavicon;
                } else {
                    if (substr($namaFavicon, 0, 9) == substr($folder_image, 0, 9)) {
                        $url_favicon = $namaFavicon;
                    } else {
                        $url_favicon = $folder_image . $namaFavicon;
                    }
                }
            }


            $data = array(
                'nama' => $this->request->getVar('nama'),
                'alamat' => $this->request->getVar('alamat'),
                'telp' => $this->request->getVar('telp'),
                'telp2' => $this->request->getVar('telp2'),
                'telp3' => $this->request->getVar('telp3'),
                'telp4' => $this->request->getVar('telp4'),
                'telp5' => $this->request->getVar('telp5'),
                'cs' => $this->request->getVar('cs'),
                'cs2' => $this->request->getVar('cs2'),
                'cs3' => $this->request->getVar('cs3'),
                'cs4' => $this->request->getVar('cs4'),
                'cs5' => $this->request->getVar('cs5'),
                'jenis_wa' => $this->request->getVar('jenis_wa'),
                'fax' => $this->request->getVar('fax'),
                'email' => $this->request->getVar('email'),
                'email2' => $this->request->getVar('email2'),
                'email3' => $this->request->getVar('email3'),
                'email4' => $this->request->getVar('email4'),
                'email5' => $this->request->getVar('email5'),
                'copyright' => $this->request->getVar('copyright'),
                'url' => $this->request->getVar('url'),
                'logo' => $url_image,
                'favicon' => $url_favicon,
            );

            $this->Perusahaan_Model->update_data($data, $id);

            return redirect()->to(base_url('perusahaan'));
        }

    }

    public function delete($id)
    {
        $data = array(
            'trash' => 1,
        );

        $this->Perusahaan_Model->update_data($data, $id);

        return redirect()->to(base_url('perusahaan'));
    }


    function simpan_active()
    {

        $id = $this->request->getVar('ids');

        $active = $this->request->getVar('cek');

        $data = array(
            'active' => $active,
        );


        $this->perusahaan->update_tentang_kami($data, $id);


    }

}
?>

WonXd677 Sh3LL