<commit_before><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Main_site extends CI_Controller {


public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        $this->load->model("user_model", "user");
    //   $this->load->model("Auth_model", "auth");
	//	$result = $this->auth->login($_SERVER['REMOTE_USER']);
	//	if(!$result[0]) {
	//		if($result[1]=="invalid") header("Location: ".base_url("invalid"));
	//		elseif($result[1]=="first_login") header("Location: ".base_url("first_login"));
	//	}
    }

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		/*This retrieves the serial numbers from the database so they can be passed to the splash page*/
		$data['serials'] = $this->user->serials_lookup();
		/*For the navbar, so it knows to highlight the home page*/
		$page["page"]=0;
		$this->load->view('header',$page);
		$this->load->view('splash_page',$data);
		$this->load->view('footer');

	}


	public function logbook_page1($url_serial)
	{
		/*echo $url_serial;*/
		/*Collects the record of the serial number defined in the page's url*/
		$record_data['records'] = $this->user->get_data($url_serial);

		$page["page"]=1;
		$this->load->view('header',$page);
		$this->load->view('logbook_page1',$record_data);
		$this->load->view('footer');
	}



	public function splash_page_continue(){

		$existing_serial = $this->input->post('existing_serial');
		$new_serial_number = $this->input->post('new_serial_number');
		$new_system_type = $this->input->post('new_system_type');
		echo $existing_serial;
		echo $new_serial_number;
		echo $new_system_type;

		/*An existing Serial has been selected from the dropdown - load that record*/
		if($existing_serial != ""){
					$path = site_url('main_site/logbook_page1/') ."/" .$existing_serial;
					header("location:".$path);
		}

			/*Neither an exising serial has been selected, nor a new one has been entered, just reload the splashpage*/
		else{
			if($new_serial_number == ""){
				$path = site_url('main_site/');
				header("location:".$path);
			}
				/*No existing serial number selected, but a new one's been entered - create a new record and go to that page*/
				else{
					echo "loc2";
				/*Create record and return the new serial number*/
				$new_id = $this->user->new_record();
				$path = site_url('main_site/logbook_page1/') ."/" .$new_id;
				header("location:".$path);
				}
		}
	}

/*
	public function database()
	{
		$data = array();
		$database = FALSE;
		 $this->load->library('form_validation');
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>'); <commit_msg>Reordered the order of functions in main site<commit_after><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Main_site extends CI_Controller {


public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        $this->load->model("user_model", "user");
    //   $this->load->model("Auth_model", "auth");
	//	$result = $this->auth->login($_SERVER['REMOTE_USER']);
	//	if(!$result[0]) {
	//		if($result[1]=="invalid") header("Location: ".base_url("invalid"));
	//		elseif($result[1]=="first_login") header("Location: ".base_url("first_login"));
	//	}
    }

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		/*This retrieves the serial numbers from the database so they can be passed to the splash page*/
		$data['serials'] = $this->user->serials_lookup();
		/*For the navbar, so it knows to highlight the home page*/
		$page["page"]=0;
		$this->load->view('header',$page);
		$this->load->view('splash_page',$data);
		$this->load->view('footer');

	}

	public function splash_page_continue(){

		$existing_serial = $this->input->post('existing_serial');
		$new_serial_number = $this->input->post('new_serial_number');
		$new_system_type = $this->input->post('new_system_type');
		echo $existing_serial;
		echo $new_serial_number;
		echo $new_system_type;

		/*An existing Serial has been selected from the dropdown - load that record*/
		if($existing_serial != ""){
					$path = site_url('main_site/logbook_page1/') ."/" .$existing_serial;
					header("location:".$path);
		}

			/*Neither an exising serial has been selected, nor a new one has been entered, just reload the splashpage*/
		else{
			if($new_serial_number == ""){
				$path = site_url('main_site/');
				header("location:".$path);
			}
				/*No existing serial number selected, but a new one's been entered - create a new record and go to that page*/
				else{
					echo "loc2";
				/*Create record and return the new serial number*/
				$new_id = $this->user->new_record();
				$path = site_url('main_site/logbook_page1/') ."/" .$new_id;
				header("location:".$path);
				}
		}
	}

	public function logbook_page1($url_serial)
	{
		/*echo $url_serial;*/
		/*Collects the record of the serial number defined in the page's url*/
		$record_data['records'] = $this->user->get_data($url_serial);

		$page["page"]=1;
		$this->load->view('header',$page);
		$this->load->view('logbook_page1',$record_data);
		$this->load->view('footer');
	}

/*
	public function database()
	{
		$data = array();
		$database = FALSE;
		 $this->load->library('form_validation');
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>'); 
{'fraction_non_alphanumeric': 0.17446876497843106, 'fraction_numerical': 0.003195398625978591, 'mean_word_length': 3.856477889837083, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 81, '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': '3613518', 'n_tokens_mistral': 2261, 'n_tokens_neox': 2037, 'n_words': 483}