<commit_before><?php
if(!defined("BASEPATH")) exit("No direct access to the script is allowed");

class House extends MY_Controller
{
	var $active_groups;
	var $houses_combo;
	function __construct()
	{
		parent:: __construct();
		$this->load->model('house_model');

		$this->load->library('upload');
        
        $this->pic_path = realpath(APPPATH . '../uploads/');
	}
	function index()
	{
		$data['content_page'] = 'house/houses';
		$data['sidebar'] = 'hr_side_bar';
		$data['houses_c'] = $this->all_house_combo();
		$data['all_houses'] = $this->all_houses();
		$data['housetypes'] = $this->gethousetypes();
		// echo "<pre>";print_r($data);die();
		$this->template->call_template($data);
	}


	function registration()
	{
		$path = base_url().'uploads/houses/';
		       $config['upload_path'] = 'uploads/houses';
		       $config['allowed_types'] = 'jpeg|jpg|png|gif';
		       $config['encrypt_name'] = TRUE;
		       $this->load->library('upload', $config);
		       $this->upload->initialize($config);

		      
			if ( ! $this->upload->do_upload('housepicture'))
		    {
			   $error = array('error' => $this->upload->display_errors());

			   print_r($error);die;
		    }
		     else
		     {
		       
                $data = array('upload_data' => $this->upload->data());
			     foreach ($data as $key => $value) {
				  //print_r($data);die;
				  $path = base_url().'uploads/houses/'.$value['file_name'];
				
                  }

		$houseno = $this->input->post('houseno');
		$housetype = $this->input->post('housetype');
		$houseblock = $this->input->post('houseblock');
		$houseestate = $this->input->post('houseestate');
		$houserent = $this->input->post('houserent');
		$housebedrooms = $this->input->post('housebedrooms');
		$housebathrooms = $this->input->post('housebathrooms');
		$housekitchen = $this->input->post('housekitchen');
		$housedescription = $this->input->post('housedescription');
// print_r($_FILES);
		$insert = $this->house_model->register_house($houseno, $housetype, $houseblock, $houseestate, $houserent, $path, $housebedrooms, $housebathrooms, $housekitchen, $housedescription);

		if ($insert) {
			echo "Insertion complete";
		} else {
			echo "Error occured";
		}
		    }
		
	}

	

	function gethousetypes()
	{
        $results = $this->house_model->get_house_types();
        
        //echo '<pre>';print_r($results);echo '</pre>';die;
            $prodcat ='<option selected="selected" value="">Select the House Type</option>';
        foreach ($results as $value) {
            $prodcat .= '<option value="' . $value['type'] . '">' . $value['type'] . '</option>';  
        }
        return $prodcat;
	}



	function all_houses()
	{
		$active_job_groups = $this->house_model->get_all_houses();<commit_msg>Small changes<commit_after><?php
if(!defined("BASEPATH")) exit("No direct access to the script is allowed");

class House extends MY_Controller
{
	var $active_groups;
	var $houses_combo;
	function __construct()
	{
		parent:: __construct();
		$this->load->model('house_model');

		$this->load->library('upload');
        
        $this->pic_path = realpath(APPPATH . '../uploads/');
	}
	function index()
	{
		$data['content_page'] = 'house/houses';
		$data['sidebar'] = 'hr_side_bar';
		$data['houses_c'] = $this->all_house_combo();
		$data['all_houses'] = $this->all_houses();
		$data['housetypes'] = $this->gethousetypes();
		// echo "<pre>";print_r($data);die();
		$this->template->call_template($data);
	}


	function registration()
	{
		$path = base_url().'uploads/houses/';
		       $config['upload_path'] = 'uploads/houses';
		       $config['allowed_types'] = 'jpeg|jpg|png|gif';
		       $config['encrypt_name'] = TRUE;
		       $this->load->library('upload', $config);
		       $this->upload->initialize($config);

		      
			if ( ! $this->upload->do_upload('housepicture'))
		    {
			   $error = array('error' => $this->upload->display_errors());

			   print_r($error);die;
		    }
		     else
		     {
		       
                $data = array('upload_data' => $this->upload->data());
			     foreach ($data as $key => $value) {
				  //print_r($data);die;
				  $path = base_url().'uploads/houses/'.$value['file_name'];
				
                  }

		$houseno = $this->input->post('houseno');
		$housetype = $this->input->post('housetype');
		$houseblock = $this->input->post('houseblock');
		$houseestate = $this->input->post('houseestate');
		$houserent = $this->input->post('houserent');
		$housebedrooms = $this->input->post('housebedrooms');
		$housebathrooms = $this->input->post('housebathrooms');
		$housekitchen = $this->input->post('housekitchen');
		$housedescription = $this->input->post('housedescription');
// print_r($_FILES);
		$insert = $this->house_model->register_house($houseno, $housetype, $houseblock, $houseestate, $houserent, $path, $housebedrooms, $housebathrooms, $housekitchen, $housedescription);

		if ($insert) {
			echo "Insertion complete";
		} else {
			echo "Error occured";
		}
		    }
		
	}

	

	function gethousetypes()
	{
        $results = $this->house_model->get_house_types();
        
        //echo '<pre>';print_r($results);echo '</pre>';die;
            $houtyp ='<option selected="selected" value="">Select the House Type</option>';
        foreach ($results as $value) {
            $houtyp .= '<option value="' . $value['type'] . '">' . $value['type'] . '</option>';  
        }
        return $houtyp;
	}



	function all_houses()
	{
		$active_job_groups = $this->house_model->get_all_houses();
{'fraction_non_alphanumeric': 0.20076238881829733, 'fraction_numerical': 0.0, 'mean_word_length': 3.379968203497615, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '667367', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1812, 'n_words': 284}