<commit_before><?php
class Contract_model extends CI_Model {
    
	// basic create function for contract
	public function create_contract($array){
		$contract_sql = "
			INSERT INTO contract(
				id,
				employer_id,
				employee_id,
				task_id,
				offer_id, 
				created_datetime, 
				last_updated_datetime, 
				completion_status
			) VALUES (
				?,
				?,
				?,
				?,
				?,
				now(), 
				now(),
				?
			)";
		return $this->db->query($contract_sql, $array);
	}
	
	// basic read function for contract (search by id)
	public function get_contract_by_id($contract_id){
		$contract_sql = "
			SELECT 
				c.id, 
				c.employer_id,
				c.employee_id,
				c.task_id,
				c.offer_id, 
				c.created_datetime, 
				c.last_updated_datetime,
				c.completion_status
			FROM 
				contract c
			WHERE 
				c.id = ?
		";
		return $this->db->query($contract_sql, $contract_id)->result_array();
	}<commit_msg>AL limited non admin contract access<commit_after><?php
class Contract_model extends CI_Model {
    
	// basic create function for contract
	public function create_contract($array){
		$contract_sql = "
			INSERT INTO contract(
				id,
				employer_id,
				employee_id,
				task_id,
				offer_id, 
				created_datetime, 
				last_updated_datetime, 
				completion_status
			) VALUES (
				?,
				?,
				?,
				?,
				?,
				now(), 
				now(),
				?
			)";
		return $this->db->query($contract_sql, $array);
	}
	
	// basic read function for contract (search by id)
	public function get_contract_by_id($contract_id){
		$contract_sql = "
			SELECT 
				c.id, 
				c.employer_id,
				c.employee_id,
				c.task_id,
				c.offer_id, 
				c.created_datetime, 
				c.last_updated_datetime,
				c.completion_status
			FROM 
				contract c
			WHERE 
				c.id = ?
		";
		return $this->db->query($contract_sql, $contract_id)->result_array();
	}
	
	// read all contracts by a user (both as employee and employer)
	public function get_all_contracts_by_user($user_id){
		$contract_sql = "
			SELECT 
				c.id, 
				a1.username as employer_username,
				a2.username as employee_username,
				t.title,
				c.offer_id, 
				c.created_datetime, 
				c.last_updated_datetime,
				c.completion_status
			FROM 
				contract c, account a1, account a2, task t
			WHERE 
				a1.id=c.employer_id AND
				a2.id=c.employee_id AND
				t.id=c.task_id AND
				(a1.id=? OR a2.id=?)
		";
		return $this->db->query($contract_sql, [$user_id, $user_id])->result_array();
	}
{'fraction_non_alphanumeric': 0.11311475409836065, 'fraction_numerical': 0.003278688524590164, 'mean_word_length': 2.659670164917541, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '1868784', 'n_tokens_mistral': 1142, 'n_tokens_neox': 868, 'n_words': 176}