HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/barbeatleanalyti/www/mbaris.beatleanalytics.com/application/controllers/Beatle_survey2.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Beatle_survey2 extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model('Beatle_survey2_model');
        $this->load->helper('url');
        $this->load->library('form_validation');
    }

    public function index()
    {
        $data = $this->Beatle_survey2_model->get_all();
        $this->output
            ->set_content_type('application/json')
            ->set_output(json_encode($data));
    }

    public function show($id)
    {
        $data = $this->Beatle_survey2_model->get_by_id($id);
        if ($data) {
            $this->output
                ->set_content_type('application/json')
                ->set_output(json_encode($data));
        } else {
            $this->output
                ->set_status_header(404)
                ->set_content_type('application/json')
                ->set_output(json_encode(['message' => 'Not Found']));
        }
    }

    public function store()
    {
        $data = $this->input->post();
        $this->form_validation->set_data($data);
        $this->form_validation->set_rules('db_surveyBranchid', 'Survey Branch ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyUserid', 'Survey User ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyIndId', 'Survey Ind ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyPageid', 'Survey Page ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyContentId', 'Survey Content ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyValue', 'Survey Value', 'required|max_length[510]');
        $this->form_validation->set_rules('created_date', 'Created Date', 'required|valid_date');
        $this->form_validation->set_rules('updated_date', 'Updated Date', 'required|valid_date');
        $this->form_validation->set_rules('tokenid', 'Token ID', 'max_length[100]');
        $this->form_validation->set_rules('orgid', 'Organization ID', 'integer');
        $this->form_validation->set_rules('is_submit', 'Is Submit', 'required|in_list[Y,N]');
        $this->form_validation->set_rules('keyword', 'Keyword', 'max_length[255]');
        $this->form_validation->set_rules('paxNo', 'Pax Number', 'max_length[255]');
        $this->form_validation->set_rules('totalBill', 'Total Bill', 'max_length[255]');
        $this->form_validation->set_rules('servername', 'Server Name', 'max_length[255]');

        if ($this->form_validation->run() === FALSE) {
            $errors = $this->form_validation->error_array();
            $this->output
                ->set_status_header(400)
                ->set_content_type('application/json')
                ->set_output(json_encode(['errors' => $errors]));
            return;
        }

        $this->Beatle_survey2_model->insert($data);
        $this->output
            ->set_status_header(201)
            ->set_content_type('application/json')
            ->set_output(json_encode($data));
    }

    public function update($id)
    {
        $data = $this->input->post();
        $this->form_validation->set_data($data);
        $this->form_validation->set_rules('db_surveyBranchid', 'Survey Branch ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyUserid', 'Survey User ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyIndId', 'Survey Ind ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyPageid', 'Survey Page ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyContentId', 'Survey Content ID', 'required|integer');
        $this->form_validation->set_rules('db_surveyValue', 'Survey Value', 'required|max_length[510]');
        $this->form_validation->set_rules('created_date', 'Created Date', 'required|valid_date');
        $this->form_validation->set_rules('updated_date', 'Updated Date', 'required|valid_date');
        $this->form_validation->set_rules('tokenid', 'Token ID', 'max_length[100]');
        $this->form_validation->set_rules('orgid', 'Organization ID', 'integer');
        $this->form_validation->set_rules('is_submit', 'Is Submit', 'required|in_list[Y,N]');
        $this->form_validation->set_rules('keyword', 'Keyword', 'max_length[255]');
        $this->form_validation->set_rules('paxNo', 'Pax Number', 'max_length[255]');
        $this->form_validation->set_rules('totalBill', 'Total Bill', 'max_length[255]');
        $this->form_validation->set_rules('servername', 'Server Name', 'max_length[255]');

        if ($this->form_validation->run() === FALSE) {
            $errors = $this->form_validation->error_array();
            $this->output
                ->set_status_header(400)
                ->set_content_type('application/json')
                ->set_output(json_encode(['errors' => $errors]));
            return;
        }

        if ($this->Beatle_survey2_model->update($id, $data)) {
            $this->output
                ->set_content_type('application/json')
                ->set_output(json_encode($data));
        } else {
            $this->output
                ->set_status_header(404)
                ->set_content_type('application/json')
                ->set_output(json_encode(['message' => 'Not Found']));
        }
    }

    public function delete($id)
    {
        if ($this->Beatle_survey2_model->delete($id)) {
            $this->output
                ->set_status_header(204)
                ->set_content_type('application/json')
                ->set_output(json_encode(['message' => 'Deleted']));
        } else {
            $this->output
                ->set_status_header(404)
                ->set_content_type('application/json')
                ->set_output(json_encode(['message' => 'Not Found']));
        }
    }
}