https://t.me/RX1948
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 :  /var/www/blue-sky.co.id/public_html/application/controllers/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/blue-sky.co.id/public_html/application/controllers/admin/Hotels.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Hotels extends Admin_Controller
{

    function __construct()
    {

        parent::__construct();
        //admin role module check
        // $this->check_admin_role('hotels'); //method from Admin_controller
        $this->load->model('hotels_m');
    }

    function index()
    {

        //pagination in action. 100 results per page
        $this->load->library('pagination');
        $config['base_url'] = base_url() . 'admin/hotels/index';
        $config['per_page'] = 100;
        $config["uri_segment"] = 4;

        //fetch all hotels
        $config['total_rows'] = $this->hotels_m->record_count();
        $this->pagination->initialize($config);
        $this->data['hotels'] = $this->hotels_m->get_all_hotels(
            $config["per_page"],
            $this->uri->segment(4)
        );

        //load view
        $this->data['subview'] = 'admin/hotels/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 refreshDisplayPriority()
    {

        $this_data = $this->input->post('this_data');

        foreach ($this_data as $key) {
            $u_data = array(
                'priority' => $key['val'],
            );
            $this->db->update('hotels', $u_data, array('id' => $key['id']));
        }
        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hotel Priority berhasil diubah</p>');

        echo json_encode(array(
            "res" => "sukses",
            // "data"=>$this_data,
        ));
    }

    function changeStatusAct()
    {
        $this_id = $this->input->post('this_id');
        $toStat = $this->input->post('toStat');

        $codeStat = null;
        if ($toStat == "Ya") {
            $codeStat = '1';
        } else {
            $codeStat = '0';
        }

        $data = array(
            "status" => $codeStat,
        );

        $upd = $this->db->update('hotels', $data, array('id' => $this_id));

        if ($upd) {
            echo json_encode(array(
                "res" => "sukses",
            ));
        }
    }

    function add()
    {

        $this->data['hotels'] = $this->hotels_m->get_new();
        $this->data['hotel_features'] = $this->hotels_m->get_new_features();
        //get ordering number and display at add form

        $this->db->select_max('priority')->from('hotels');
        $current_priority = $this->db->get()->row()->priority;
        if ($current_priority == NULL) {
            $this->data['hotels']->priority = 1;
        } else {
            $this->data['hotels']->priority = $current_priority + 1;
        }

        //validation check in action
        $config = array(
            array(
                'field'   => 'name',
                'label'   => 'Hotel Name',
                'rules'   => 'trim|required'
            ),
            array(
                'field'   => 'priority',
                'label'   => 'Priority',
                'rules'   => 'trim|required|numeric'
            ),
            array(
                'field'   => 'status',
                'label'   => 'status',
                'rules'   => 'trim|required'
            )
        );

        $this->load->library('form_validation');
        $this->form_validation->set_rules($config);
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');

        if ($this->form_validation->run() == TRUE) {

            if ($_POST) {

                $data = array(
                    'name' => $this->security->xss_clean($this->input->post('name')),
                    'alias' => url_title($this->security->xss_clean($this->input->post('name'))),
                    'priority' => $this->input->post('priority'),
                    'status' => $this->input->post('status')
                );

                $hotel_id = $this->hotels_m->add_hotels($data);

                $data_role = array(
                    "role_name" => "Hotel ID : " . $hotel_id,
                );
                $this->db->insert('role', $data_role);

                if ($_FILES['feature1_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature1_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature1_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image1 = $this->upload->data();
                        $image1_filename = $image1['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature2_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature2_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature2_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image2 = $this->upload->data();
                        $image2_filename = $image2['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature3_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature3_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature3_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image3 = $this->upload->data();
                        $image3_filename = $image3['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature4_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature4_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature4_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image4 = $this->upload->data();
                        $image4_filename = $image4['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature5_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature5_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature5_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image5 = $this->upload->data();
                        $image5_filename = $image5['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature6_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature6_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature6_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image6 = $this->upload->data();
                        $image6_filename = $image6['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature7_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature7_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature7_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image7 = $this->upload->data();
                        $image7_filename = $image7['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature8_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature8_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature8_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image8 = $this->upload->data();
                        $image8_filename = $image8['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature9_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature9_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature9_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $image9 = $this->upload->data();
                        $image9_filename = $image9['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }


                $data = array(
                    'hotel_id' => $hotel_id,
                    'feature1' => $this->input->post('feature1'),
                    'feature2' => $this->input->post('feature2'),
                    'feature3' => $this->input->post('feature3'),
                    'feature4' => $this->input->post('feature4'),
                    'feature5' => $this->input->post('feature5'),
                    'feature6' => $this->input->post('feature6'),
                    'feature7' => $this->input->post('feature7'),
                    'feature8' => $this->input->post('feature8'),
                    'feature9' => $this->input->post('feature9')
                );

                if ($_FILES['img_logo']['size'] !== 0) {

                    $config['upload_path'] = './uploads/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    $config['max_width']  = '96';
                    $config['max_height']  = '169';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('img_logo')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('img_logo', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $img_logo = $this->upload->data();
                        $img_logo_filename = $image1['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }
                if (isset($img_logo_filename)) {
                    $data['logo'] = $img_logo_filename;
                }
                if (isset($image1_filename)) {
                    $data['feature1_img'] = $image1_filename;
                }
                if (isset($image2_filename)) {
                    $data['feature2_img'] = $image2_filename;
                }
                if (isset($image3_filename)) {
                    $data['feature3_img'] = $image3_filename;
                }
                if (isset($image4_filename)) {
                    $data['feature4_img'] = $image4_filename;
                }
                if (isset($image5_filename)) {
                    $data['feature5_img'] = $image5_filename;
                }
                if (isset($image6_filename)) {
                    $data['feature6_img'] = $image6_filename;
                }
                if (isset($image7_filename)) {
                    $data['feature7_img'] = $image7_filename;
                }
                if (isset($image8_filename)) {
                    $data['feature8_img'] = $image8_filename;
                }
                if (isset($image9_filename)) {
                    $data['feature9_img'] = $image9_filename;
                }
                $this->hotels_m->add_hotel_features($data);



                $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hotel berhasil ditambahkan</p>');

                redirect('admin/hotels');
            }
        }

        $this->data['subview'] = 'admin/hotels/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 edit($id = NULL)
    {

        //check if id exist. If not exist, show 404.
        $count = $this->hotels_m->count_exist($id);
        $count2 = $this->hotels_m->count_exist_features($id);

        if ($count == 0 && $count2 == 0) {
            //page not exist
            show_404();
        }

        $this->data['hotels'] = $this->hotels_m->get($id);
        $this->data['hotel_features'] = $this->hotels_m->get_hotel_features($id);
        //validation check in action
        $config = array(
            array(
                'field'   => 'name',
                'label'   => 'Hotel Name',
                'rules'   => 'trim|required'
            ),
            array(
                'field'   => 'priority',
                'label'   => 'Priority',
                'rules'   => 'trim|required|numeric'
            ),
            array(
                'field'   => 'status',
                'label'   => 'status',
                'rules'   => 'trim|required'
            )
        );
        $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);

        if ($this->form_validation->run() == TRUE) {

            if ($_POST) {

                $data = array(
                    'name' => $this->security->xss_clean($this->input->post('name')),
                    'alias' => url_title($this->security->xss_clean($this->input->post('name'))),
                    'priority' => $this->input->post('priority'),
                    'status' => $this->input->post('status')
                );

                $this->hotels_m->edit_hotels($id, $data);

                $data_role = array(
                    "role_name" => "Hotel ID : " . $id,
                );
                $quer_role_hotel = $this->db->get_where("role", $data_role);
                if ($quer_role_hotel->num_rows() == 0) {
                    $this->db->insert('role', $data_role);
                }

                if ($_FILES['feature1_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature1_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature1_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image1 = $this->upload->data();
                        $image1_filename = $image1['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature2_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature2_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature2_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image2 = $this->upload->data();
                        $image2_filename = $image2['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature3_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature3_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature3_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image3 = $this->upload->data();
                        $image3_filename = $image3['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature4_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature4_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature4_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image4 = $this->upload->data();
                        $image4_filename = $image4['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature5_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature5_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature5_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image5 = $this->upload->data();
                        $image5_filename = $image5['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature6_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature6_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature6_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image6 = $this->upload->data();
                        $image6_filename = $image6['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature7_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature7_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature7_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image7 = $this->upload->data();
                        $image7_filename = $image7['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature8_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature8_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature8_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image8 = $this->upload->data();
                        $image8_filename = $image8['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }

                if ($_FILES['feature9_img']['size'] !== 0) {

                    $config['upload_path'] = './uploads/home_about/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    // $config['max_width']  = '800';
                    // $config['max_height']  = '800';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('feature9_img')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('feature9_img', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/edit/' . $id);
                    } else {
                        $image9 = $this->upload->data();
                        $image9_filename = $image9['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }


                $data = array(
                    'hotel_id' => $id,
                    'feature1' => $this->input->post('feature1'),
                    'feature2' => $this->input->post('feature2'),
                    'feature3' => $this->input->post('feature3'),
                    'feature4' => $this->input->post('feature4'),
                    'feature5' => $this->input->post('feature5'),
                    'feature6' => $this->input->post('feature6'),
                    'feature7' => $this->input->post('feature7'),
                    'feature8' => $this->input->post('feature8'),
                    'feature9' => $this->input->post('feature9')
                );

                if ($_FILES['img_logo']['size'] !== 0) {

                    $config['upload_path'] = './uploads/';
                    $config['allowed_types'] = 'jpg|png|gif';
                    $config['max_size']  = '200';
                    $config['max_width']  = '96';
                    $config['max_height']  = '169';

                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);

                    if (!$this->upload->do_upload('img_logo')) {

                        //echo $this->upload->display_errors(); die();

                        $this->session->set_flashdata('img_logo', '<br>
		                    <p style="background:orange; color:white; padding:5px; font-weight:bold;">Kesalahan Unggah Gambar. Format atau ukuran salah.</p>');

                        redirect('admin/hotels/add');
                    } else {
                        $img_logo = $this->upload->data();
                        $img_logo_filename = $image1['file_name'];

                        // $this->resize_single_image('800','800','',$image_not_available_filename);         
                    }
                }
                if (isset($img_logo_filename)) {
                    $data['logo'] = $img_logo_filename;
                }
                if (isset($image1_filename)) {
                    $data['feature1_img'] = $image1_filename;
                }
                if (isset($image2_filename)) {
                    $data['feature2_img'] = $image2_filename;
                }
                if (isset($image3_filename)) {
                    $data['feature3_img'] = $image3_filename;
                }
                if (isset($image4_filename)) {
                    $data['feature4_img'] = $image4_filename;
                }
                if (isset($image5_filename)) {
                    $data['feature5_img'] = $image5_filename;
                }
                if (isset($image6_filename)) {
                    $data['feature6_img'] = $image6_filename;
                }
                if (isset($image7_filename)) {
                    $data['feature7_img'] = $image7_filename;
                }
                if (isset($image8_filename)) {
                    $data['feature8_img'] = $image8_filename;
                }
                if (isset($image9_filename)) {
                    $data['feature9_img'] = $image9_filename;
                }

                // $this->hotels_m->edit_hotels($id, $data);
                $this->hotels_m->edit_hotel_features($id, $data);

                $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hotel berhasil diedit</p>');

                redirect('admin/hotels/edit/' . $id);
            }
        }

        $this->data['subview'] = 'admin/hotels/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 delete($id)
    {

        //check if id exist. If not exist, show 404.
        $count = $this->hotels_m->count_exist($id);

        if ($count == 0) {
            //page not exist 
            show_404();
        }

        //delete brand
        $this->hotels_m->delete($id);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Hotel berhasil dihapus</p>');
        redirect('admin/hotels');
    }

    function landing_page($id = NULL)
    {

        if ($id == NULL) {
            redirect('admin/hotels');
        }

        //check if hotel id exist
        $count_id = $this->db->select('id')->from('hotels')->where('id', $id)->get()->num_rows();
        if ($count_id == 0) {
            redirect('admin/hotels');
        }

        //get hotel data
        $this->data['hotel'] = $this->db->select('id, name, alias')->from('hotels')->where('id', $id)->where('status', '1')->get()->row();

        //create new session
        $this->session->set_userdata('hotel_id', $id);
        $this->session->set_userdata('hotel_name', $this->data['hotel']->name);

        $this->data['subview'] = 'admin/hotels/landing_page';
        $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 delete_feature1($id)
    {

        //get image file name for deletion
        $this->db->select('feature1_img')->from('hotel_features')->where('hotel_id', $id);
        $feature1_img = $this->db->get()->row()->feature1_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature1_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature1_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }

    public function delete_feature2($id)
    {

        //get image file name for deletion
        $this->db->select('feature2_img')->from('hotel_features')->where('hotel_id', $id);
        $feature2_img = $this->db->get()->row()->feature2_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature2_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature2_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }

    public function delete_feature3($id)
    {

        //get image file name for deletion
        $this->db->select('feature3_img')->from('hotel_features')->where('hotel_id', $id);
        $feature3_img = $this->db->get()->row()->feature3_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature3_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature3_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }

    public function delete_feature4($id)
    {

        //get image file name for deletion
        $this->db->select('feature4_img')->from('hotel_features')->where('hotel_id', $id);
        $feature4_img = $this->db->get()->row()->feature4_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature4_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature4_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }

    public function delete_feature5($id)
    {

        //get image file name for deletion
        $this->db->select('feature5_img')->from('hotel_features')->where('hotel_id', $id);
        $feature5_img = $this->db->get()->row()->feature5_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature5_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature5_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }

    public function delete_feature6($id)
    {

        //get image file name for deletion
        $this->db->select('feature6_img')->from('hotel_features')->where('hotel_id', $id);
        $feature6_img = $this->db->get()->row()->feature6_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature6_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature6_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }

    public function delete_feature7($id)
    {

        //get image file name for deletion
        $this->db->select('feature7_img')->from('hotel_features')->where('hotel_id', $id);
        $feature7_img = $this->db->get()->row()->feature7_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature7_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature7_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }

    public function delete_feature8($id)
    {

        //get image file name for deletion
        $this->db->select('feature8_img')->from('hotel_features')->where('hotel_id', $id);
        $feature8_img = $this->db->get()->row()->feature8_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature8_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature8_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }

    public function delete_feature9($id)
    {

        //get image file name for deletion
        $this->db->select('feature9_img')->from('hotel_features')->where('hotel_id', $id);
        $feature8_img = $this->db->get()->row()->feature9_img;

        //Delete the actual image file from server. FCPATH is codeigniter base path
        unlink(FCPATH . '/uploads/home_about/' . $feature9_img);

        //Delete website_icon field from configuration database
        $data = array(
            'feature9_img' => '',
        );

        $this->db->where('hotel_id', $id);
        $this->db->update('hotel_features', $data);

        $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Gambar Icon Berhasil Dihapus</p>');

        redirect('admin/hotels/edit/' . $id);
    }
}

https://t.me/RX1948 - 2025